PDA

View Full Version : Confusion on how a dockable widgets decide where they can go



SeanM
11th February 2014, 18:42
I'm encountering a weird oddity with QDockWidgets, and can't figure out what's causing the behavior... I've attached a small demo that should replicate the problem.

I want a QMainWindow with two types of dock based widgets. In my demo, they're QLineEdits and QTextEdits, in my real app the QTextEdits will be replaced with QwtPlots, but that doesn't seem to be the root of the problem. When the app starts, I want all the QLineEdits in a column on the left side, and all the QTextEdits on the right as shown:
10034

So far so good, then the user decides that they would like to put Text Edit 0 up on top, spanning the two columns like so:
10035
So the user grabs the title bar for Text Edit 0, drags it up towards the top until he gets the indicator that it will span both columns and drops it. This works great - when there's 12 QLineEdits and 3 QTextEdits.

But then if I go into my code, in mainwindow.cpp, line 106 and simply change the number of QLineEdits from 12 to 13, the functionality breaks

for (int i=0; i < 13; i++)
In this version, the QTextEdits only want to dock in the same column they're already at the start. If the user moves a QLineEdit around first before they can move Text Edit 0, up to the top. But I can't seem to get the behavior to be consistent... The best I can do is this: where Text Edit 0 is on top, but Line Edit 0 now has to be in the right column.
10036
And the steps I took to get there was to move Line Edit 0 to the top, spanning both columns, then Text Edit 0 up next to it, then moved Line Edit 0 down to the right column (it refused to go back into the left column. And all it took for this behavior to change is by adding one more QLineEdit...