PDA

View Full Version : hideEvent not propagated to tabified dock widgets



spud
2nd October 2007, 18:04
I am trying to catch the hide/show events in a widget which has been placed in a QDockWidget. The problem is that after I tabify the Dockwidget, it doesn't get those notifications anymore when I switch tabs. This behaviour differs from that of an ordinary QTabWidget.

I am using Qt 4.3.0 at the moment and I would like to know if this is wanted behaviour, or if it has been fixed in the 4.4 branch, otherwise I'll file a bug report.

Here is an example to test the behaviour:



#include <QtGui>

class MyLabel : public QLabel
{
public:
MyLabel()
: timesHidden(0)
, timesShown(0)
{
}
void showEvent(QShowEvent*)
{
timesShown++;
QString text;
text.sprintf("Times hidden: %d\nTimes Shown: %d", timesHidden, timesShown);
setText(text);
}
void hideEvent(QHideEvent*)
{
timesHidden++;
}
int timesHidden;
int timesShown;
};

int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QMainWindow window;
window.setCentralWidget(new QTextEdit(&window));

QList<QDockWidget*> dockWidgets;
for (int i=1;i<=3;i++){
QDockWidget* dock = new QDockWidget(QString::number(i), &window);
dock->setWidget(new MyLabel);
window.addDockWidget(Qt::BottomDockWidgetArea, dock);
dockWidgets << dock;
}
window.tabifyDockWidget(dockWidgets[1], dockWidgets[2]);

window.show();
return app.exec();
}

spud
4th October 2007, 08:48
So, should I consider this a bug? I would really appreciate if somebody would test it.

jpn
4th October 2007, 10:00
I haven't had time to look into it, but perhaps you could use QDockWidget::visibilityChanged()?