10

By liuyanghejerry

No Comments

Categories: Qt Widget

Tags: , ,

AutoAdvance in QTimeEdit

AutoAdvance, is a feature that allows you step up or down in whole sections. For example, when 4:59 and you try to step up, you will get 5:00, when the feature is enabled.

This is a useful feature but disappeared since Qt 3.3. And below, is my own method to implement it.


class myTime : public QTimeEdit
{
Q_OBJECT
public:
virtual void stepBy(int steps)
{
if (this->time().minute()==59 && steps>0){
setTime(QTime(time().hour()+1,0,time().second(),time().msec()));
}else if(this->time().minute()==00 && steps<0){
setTime(QTime(time().hour()-1,59,time().second(),time().msec()));
}else{
QTimeEdit::stepBy(steps);
}
}
};

Keep in mind, to enable the code beyond, must setWrapping(true).

17

By liuyanghejerry

No Comments

Categories: Qt Widget

Tags: , ,

QGradualBox

QGradualBox is a widget that can show messages faded in and faded out. Using this way to notify user may be more user-friendly.

However, due to the asynchronous function setText()  while all the other settings functions are synchronous, the settings functions such as setBackgroundColor() will function immediately rather than the next setText() call.

To deal with the problem, just use the signal and slots to get the accurate opportunity the text shown down or not.

Download:QGradualBox

4

By liuyanghejerry

No Comments

Categories: Qt Widget

Tags: , ,

QIPLineEdit

There’re some people searching around a perfect IP widget with mask and rx, so this is it.

This Widget can have a mask set to 000.000.000.000, and also can limit user a valid IP address.

Source Downlaod:QIPLineEdit

4

By liuyanghejerry

No Comments

Categories: Qt Widget

Tags: , ,

QIRCLineEdit

This is a IRC chat like LineEdit widget.

It uses a QList<QString> to record the history input, and works when slot myclear() was emitted.

Source Download:

QIRCLinedit