I have an array of QWidgets created throughout the life of my application and the newest ones are always rendered on top of the oldest. I sometimes need to pull an old one on top. Is there some way to change the order that the widgets are drawn in?
I have an array of QWidgets created throughout the life of my application and the newest ones are always rendered on top of the oldest. I sometimes need to pull an old one on top. Is there some way to change the order that the widgets are drawn in?
try to create and show a same button(name of btnChangeState )in each widget,and connect all this button's click signal to one slot(name of ChangeState).In the ChangeState method,you can show a popupmenu.items of the menu is a list of your all widgets.user can select one widget on top by click menu.
show a select-widget on top :
1.hide old-top-widget and selected-widget;
2.show old-top-widget
3.show selected-widget
note:There can be only one widget is on top at the same time .
Last edited by rainspider; 5th December 2009 at 16:58.
That's not working for me. I create some widgets with something similar to this:
Then in another portion of code I reorganize the widgets and the QList and after that their default draw order is no longer appropriate. Now if I'm understanding you correctly this:Qt Code:To copy to clipboard, switch view to plain text mode
should order them so that the later indexed widgets draw on top of the earlier indexed widgets. But that's not happening. They continue to draw according to the order they were "new"ed in.Qt Code:
for(int n = 0; n < test.count(); n++) test[n]->hide(); for(int n = 0; n < test.count(); n++) test[n]->show();To copy to clipboard, switch view to plain text mode
you need to call a function QWidget::raise() it will bring that widget to the top of stack
Spectralist (6th December 2009)
Thanks! I went through the public functions list 5 or 6 times looking for a function that does this but somehow didn't think to look under the slots category.![]()
Bookmarks