Results 1 to 5 of 5

Thread: Can you change which widgets are drawn on top?

  1. #1
    Join Date
    Oct 2009
    Posts
    7
    Thanks
    3
    Platforms
    Windows

    Default Can you change which widgets are drawn on top?

    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?

  2. #2
    Join Date
    Oct 2009
    Posts
    22
    Thanks
    8
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can you change which widgets are drawn on top?

    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 15:58.

  3. #3
    Join Date
    Oct 2009
    Posts
    7
    Thanks
    3
    Platforms
    Windows

    Post Re: Can you change which widgets are drawn on top?

    That's not working for me. I create some widgets with something similar to this:
    Qt Code:
    1. QWidget * main;
    2. main = new QWidget;
    3. QList<QWidget *> test;
    4.  
    5. for(int n = 0; n < 10; n++)
    6. {
    7. QWidget * tempW;
    8. tempW = new QWidget(main);
    9.  
    10. tempW->show();
    11. tempW->move(0, n*70);
    12. test.append(tempW);
    13. }
    To copy to clipboard, switch view to plain text mode 
    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:
    1. for(int n = 0; n < test.count(); n++)
    2. test[n]->hide();
    3.  
    4. for(int n = 0; n < test.count(); n++)
    5. test[n]->show();
    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.

  4. #4
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Can you change which widgets are drawn on top?

    you need to call a function QWidget::raise() it will bring that widget to the top of stack

  5. The following user says thank you to nish for this useful post:

    Spectralist (6th December 2009)

  6. #5
    Join Date
    Oct 2009
    Posts
    7
    Thanks
    3
    Platforms
    Windows

    Default Re: Can you change which widgets are drawn on top?

    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.

Similar Threads

  1. Qt3 - Multiple transparent widgets
    By bythesea in forum Qt Programming
    Replies: 4
    Last Post: 11th September 2009, 11:24
  2. Mac OS X Top-Level Transparent Widgets
    By tinsuke in forum Qt Programming
    Replies: 0
    Last Post: 17th October 2008, 16:01
  3. Upper limit on number of widgets?
    By jdiewald in forum Qt Programming
    Replies: 1
    Last Post: 29th September 2008, 23:00
  4. Replies: 2
    Last Post: 16th May 2008, 14:39
  5. widgets behind hidden widgets not working
    By bpetty in forum Newbie
    Replies: 13
    Last Post: 7th September 2007, 20:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.