PDA

View Full Version : MDI subWindow activating when switching toolbox page



zenzero-2001
9th April 2011, 16:53
Hi everybody!

I have a weird bug in my program and I can't find what is causing it. My program is an MDI program with toolbox, which I have subclassed from QToolbox.

The steps to reproduce the bug are as follows:

1) I open two sub windows and make sure the second sub window is the active window.

2) I then click on a page area (or a control on a page) in the toolbox, therefore activating it presumably.

3) I click on a different page heading in the toolbox to switch pages. When I do this the first sub window becomes active. This shouldn't happen, switching pages in the toolbox should not affect which sub window is active.

Has anybody else experienced this problem? I pretty sure it is my mistake somewhere, but I just can't find it - but maybe it is a Qt bug (unlikely)?

I'm not using the QToolbox currentChanged signal, so I do not understand how switching a page in the toolbox can affect the sub windows? Maybe I will have to create a dummy MDI application with toolbox to see if the bug occurs with that.

Any ideas greatly appreciated. Thanks!

zenzero-2001

falconium
9th April 2011, 17:30
Is it always the frist MDI window which is activated? Have you tried to open more than two?
If it was a bug of Qt, I would store the index of active window and would activate it back later. I know, it is just a workaround.

zenzero-2001
9th April 2011, 19:23
It is always the window that was created earliest that is activated.

Yes, I could do that - it is a hack though.

zenzero-2001
10th April 2011, 13:43
I forgot to say that my toolbox is inside a dock widget.

I have taken the MDI example from the documentation and have added a basic dock widget, toolbox and two blank pages. The result is that this also exhibits the erroneous behaviour. Maybe I have found a bug in Qt?

I will do some more investigating.

Added after 7 minutes:

Ok, this is the code that I added to the standard MDI example.

First mainwindow.h , just below the #includes:


class QDockWidget;
class QToolBox;

then below private:


QDockWidget *dock;
QToolBox *toolBox;

At the end of the constructor in mainwindow.cpp :


dock = new QDockWidget(this);

toolBox = new QToolBox(this);
toolBox->addItem(new QWidget(toolBox), "Widget 1");
toolBox->addItem(new QWidget(toolBox), "Widget 2");

dock->setWidget(toolBox);
addDockWidget(Qt::RightDockWidgetArea, dock);

Can anybody else reproduce this problem or I am doing something wrong?

Added after 15 minutes:

The bug also occurs if you click on the dock widget restore button. The bug can therefore also be reproduced with a single toolbox page. The bug does not occur when there are no toolbox pages.

zenzero-2001
10th April 2011, 18:46
I've discovered that the bug does not occur when the dock widget is floating but only when it is docked.

I have opened a bug issue on the qt website