Results 1 to 3 of 3

Thread: How to raise a QWidget over QGraphicsObjects in a QGraphicsScene

  1. #1
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Question How to raise a QWidget over QGraphicsObjects in a QGraphicsScene

    Hi,
    I'm using a QGraphicsScene with several QGraphicsObjects of different zValue.
    Now I have made a Control Widget (a few QPushbuttons and QComboBoxes and Layouts on a QWidget) with QCreator and added it to the
    Qt Code:
    1. QGraphicsScene with scene->addWidget(controlWidget);
    To copy to clipboard, switch view to plain text mode 
    The problem is: the widget is being overlapped by most of the other objects in the scene.

    I tried the QWidget::raise(); method to no avail at all. Is there any way to make QWidget appear in front of all QGraphicsScene members?
    I cannot ensure that the widget is addet as last member to the scene.

    I am running out of ideas :-( Any help is welcome, thank you for reading!

    Sebastian

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: How to raise a QWidget over QGraphicsObjects in a QGraphicsScene

    Try giving your controlWidget a zValue higher than your other items:
    Qt Code:
    1. QGraphicsProxyWidget *proxyWidget = scene()->addWidget(controlWidget);
    2. proxyWidget->setZValue(1000); // or 10000 or . . .
    To copy to clipboard, switch view to plain text mode 

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

    sedi (8th April 2012)

  4. #3
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: How to raise a QWidget over QGraphicsObjects in a QGraphicsScene

    Norobro, thank you so much! My forehead aches big deal from being smashed on the table continuously for quite some time. "The very moment you do something the right way, it suddenly works". Like a charm. Thanks a ton!

Similar Threads

  1. Replies: 4
    Last Post: 28th February 2012, 12:04
  2. How can I move a QWidget across a QGraphicsScene
    By Maduka in forum Qt Programming
    Replies: 0
    Last Post: 8th November 2011, 13:40
  3. QWidget in QGraphicsScene not drawing
    By stevel in forum Qt Programming
    Replies: 3
    Last Post: 19th September 2008, 20:19
  4. QWidget in a QGraphicsScene ..!!!
    By salmanmanekia in forum Qt Programming
    Replies: 7
    Last Post: 17th July 2008, 07:07
  5. When to use QGraphicsScene or QWidget
    By fossill in forum Qt Programming
    Replies: 2
    Last Post: 10th February 2007, 00:58

Tags for this Thread

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.