PDA

View Full Version : window resizing done



chiaminhsu
22nd January 2013, 16:34
hi,

Resizing window is a continuous process -
mouse down, drag drag drag .. , mouse up

It seems that any dragging can invoke a resizing event.
Does Qt exist an event at the end of resizing ?

Thank your for any reply.

Santosh Reddy
22nd January 2013, 17:59
Resizing window is a continuous process -
It's not that stright forward to say continuous, it is actualy invidual mouse movement events triggering resizeEvent

Each resizeEvent by itself is the indication that widget should resize now. There is not concept of last event/end of resize.

In short No.

ChrisW67
22nd January 2013, 23:04
You can use a singleshot QTimer to trigger something if a resizeEvent has not been received for a certain period, say 500 milliseconds. This is approximately "the end of resizing"



#include <QtGui>
#include <QDebug>


class Widget: public QWidget {
Q_OBJECT
public:
Widget(QWidget *p = 0): QWidget(p) {
m_resizeTimer.setSingleShot(true);
connect(&m_resizeTimer, SIGNAL(timeout()), SLOT(resizeDone()));
}

protected:
void resizeEvent(QResizeEvent *e) {
qDebug() << Q_FUNC_INFO;
m_resizeTimer.start(500);
QWidget::resizeEvent(e);
}

private slots:
void resizeDone() {
qDebug() << Q_FUNC_INFO;
}

private:
QTimer m_resizeTimer;
};


int main(int argc, char**argv) {
QApplication app(argc, argv);
Widget w;
w.show();
return app.exec();
}

#include "main.moc"

chiaminhsu
23rd January 2013, 05:01
oh ... I never think about it. Thank your replay :D