Results 1 to 7 of 7

Thread: Controlling which widget on top layer?

  1. #1
    Join Date
    Jan 2007
    Posts
    81
    Thanks
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Controlling which widget on top layer?

    Hello all, as of right now my program has a main widget, which has lots of child widgets. These child widgets are painted onto the mainwidget and are transparent; so whenever the main widget gets a paintEvent the childwidgets also receive a paintEvent.

    My question is as follows: some of these child widgets overlap and I need to be able to let the user select which widget gets painted on top of the others (so one widget is in the foreground) because this top widget needs to be able to receive mouseEvents...and if a widget is not on top and is covered by another widget it will not get these mouse events...thus I need to know how to change the paint/layer order.

    Any help would be appreciated.



    Jonathan

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Controlling which widget on top layer?

    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    JonathanForQT4 (22nd March 2007)

  4. #3
    Join Date
    Jan 2007
    Posts
    81
    Thanks
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Controlling which widget on top layer?

    dude, awesome --- thank you for this.

  5. #4
    Join Date
    Jan 2007
    Posts
    81
    Thanks
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Controlling which widget on top layer?

    while I'm here, I guess I could ask my second question...there are quite a few of these child widgets....sometimes the count is larger than 10 thousand....since they all receive a paintEvent when the parent gets one (each time the mouse is moved..etc.) it bogs the program down so much that it can't display anything anymore.

    Is there a work around for this? I have tried using setUpdatesEnabled but when it is used for the children widgets...nothing gets painted as soon as the parent gets a paintEvent...

    Thanks again,

    Jonathan

  6. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Controlling which widget on top layer?

    Quote Originally Posted by JonathanForQT4 View Post
    there are quite a few of these child widgets....sometimes the count is larger than 10 thousand....since they all receive a paintEvent when the parent gets one (each time the mouse is moved..etc.) it bogs the program down so much that it can't display anything anymore.
    That's huge amount of widgets. I wouldn't suggest using so many widgets because excessive amount of child widgets tend to eat resources quite a bit as you have noticed already. Could you provide a screenshot of how the GUI looks like? Maybe there could be other possibilities like model/view or graphicsview frameworks.
    J-P Nurmi

  7. #6
    Join Date
    Jan 2007
    Posts
    81
    Thanks
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Controlling which widget on top layer?

    well....I can't provide a screenshot, but I can say the following: all you'd see is a main window with a scroll area with the scroll area's centralwidget being the mainWidget I described above. The main widget has all different types of children widgets. They are either rectangles or circles. There about about 7 types of these child widgets, but as I understand it, with the graphicsview route a type (of the 7) would be added to a graphics scene and then the scene would be painted to the mainWidget. The problem is, within one type of child widget I need to be able to to tell the difference.....because of one type of child widget, there could be a couple of thousand instances of it (which I need to be able to distinguish).
    So that begs the question: I would have to make a graphics scene for each element from each of the 7 types and then print them to the mainWidget. Would I be bogged down with memory issues like before? It seems that I can receive mouseEvents with graphics scenes so that would suffice

    As for the model/view programming, I have read the documentation, but fail to see how it would be of use in my case...but I'm sure that I've overlooked the underlying idea you are pointing to (because I'm a noob with qt)....maybe you could go more in to depth with an overview/example?

  8. #7
    Join Date
    Jan 2007
    Posts
    81
    Thanks
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Controlling which widget on top layer?

    actually nevermind...you could add seperate items to a scene since not only qgraphics scene gets mouseEvents, but also the items....so I should be able to do it on one scene....time to try it out I guess

    thanks again,

    Jonathan

Similar Threads

  1. Replies: 4
    Last Post: 10th March 2007, 19:01
  2. Replies: 1
    Last Post: 6th November 2006, 00:50
  3. Pin/Unpin Dock Widget
    By charlesD in forum Newbie
    Replies: 1
    Last Post: 21st June 2006, 07:57
  4. Replies: 4
    Last Post: 24th March 2006, 23:50
  5. [Qt 4.1.0] Split a widget on demand
    By Townk in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 15:16

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.