QSplitter uses the opaque resize flag to alter its behaviour to use a rubber band and not propagate resizes to the child widgets until the mouse is released.
As far as I can tell when the QDockwidget is floating resizing is handled by the window manager and not within Qt control.
When the QDockWidget is docked its resize behaviour would be controlled by QMainWindow layout and any splitters it may use.
If the content of the dock widget is expensive to redraw then you may be able to fake it by suppressing updates until some short time after the last resize event.
#include <QtGui>
Q_OBJECT
public:
m_resizeTimer
= new QTimer(this);
m_resizeTimer->setSingleShot(true);
m_resizeTimer->setInterval(250); // how many milliseconds after last resize event do we draw
connect(m_resizeTimer, SIGNAL(timeout()), SLOT(releaseResize()));
setStyleSheet(" Widget { background-color: blue; } ");
}
protected:
m_resizeTimer->start(); // start idle timer or restart running timer
setUpdatesEnabled(false);
QWidget::resizeEvent(event
);
// in case it is doing things that still need to happen }
private slots:
void releaseResize() {
setUpdatesEnabled(true);
}
private:
};
int main(int argc, char **argv){
Widget w;
w.resize(320, 240);
w.show();
return app.exec();
}
#include "main.moc"
#include <QtGui>
class Widget: public QWidget {
Q_OBJECT
public:
Widget(QWidget *p = 0): QWidget(p) {
m_resizeTimer = new QTimer(this);
m_resizeTimer->setSingleShot(true);
m_resizeTimer->setInterval(250); // how many milliseconds after last resize event do we draw
connect(m_resizeTimer, SIGNAL(timeout()), SLOT(releaseResize()));
setStyleSheet(" Widget { background-color: blue; } ");
}
protected:
void resizeEvent(QResizeEvent * event) {
m_resizeTimer->start(); // start idle timer or restart running timer
setUpdatesEnabled(false);
QWidget::resizeEvent(event); // in case it is doing things that still need to happen
}
private slots:
void releaseResize() {
setUpdatesEnabled(true);
}
private:
QTimer *m_resizeTimer;
};
int main(int argc, char **argv){
QApplication app(argc, argv);
Widget w;
w.resize(320, 240);
w.show();
return app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Or you could set a flag on the first resizeEvent(). Your paintEvent() should check the flag and draw something cheap if it is set, i.e. during resize. When the timer goes off reset the flag and call update() to redraw using the expensive version of paintEvent().
Bookmarks