Results 1 to 6 of 6

Thread: placing widgets on top of other widgets

  1. #1
    Join Date
    Apr 2007
    Location
    Rakovnik, Czech Republic
    Posts
    175
    Thanks
    43
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default placing widgets on top of other widgets

    Here's a link to a screen-capture that will help explain what I want to do:

    http://www.beg.utexas.edu/coastal/wrl/del/scr2.jpg

    I have a few buttons and other widgets along the top, bottom and sides of my application; the primary window is a QWidget which contains/displays a Coin3d scenegraph. When the user mouses Over some of the buttons, I want a QWidget to pop-up that will have an image and text to explain something about that button's feature ("Info Widget" in the image).

    I'm using an eventFilter to detect the mouse-Over, but I don't know how I can put one widget ("Info Widget") on top of another (the Coin3d widget). All of the examples I've seen show how Widgets/etc. can be next to each other, not one on top of the other. Is this possible?

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: placing widgets on top of other widgets

    Yes, it can be done. I have done it.

    Just create a frameless widget, with the main window as parent and set it's geometry( position actually ) wherever you want it to appear. If I remember correctly you have to work in parent coordinates.

    As long as you don't add the info widget to any layout, then you can manually adjust its position without problems.

    Regards

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

    swdev (10th June 2014)

  4. #3
    Join Date
    Apr 2007
    Location
    Rakovnik, Czech Republic
    Posts
    175
    Thanks
    43
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: placing widgets on top of other widgets

    thanks Marcel- i'm about to leave but will try it out on Monday.

  5. #4
    Join Date
    Apr 2007
    Location
    Rakovnik, Czech Republic
    Posts
    175
    Thanks
    43
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: placing widgets on top of other widgets

    hey Marcel- it's not monday yet, but oh well. I did as you suggested--assign the primary window as the widget's parent, and not add it to a layout--and it works. I'm not sure what you meant about "frameless widget", however. If I search for "frameless" in QtAssistant, I only see reference to "Qt::FramelessWindowHint". If I add the following to my application:

    Qt Code:
    1. myInfoWidget->setFrameStyle(Qt::FramelessWindowHint);
    To copy to clipboard, switch view to plain text mode 

    I don't see any change. What did you have in mind? ...or is this necessary?

  6. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: placing widgets on top of other widgets

    Well, I was looking at your draft and I thought that you wanted a widget without a title bar.
    But you are right. I got confused a bit. You don't need that flag for a QWidget.
    The widget won't have a title bar anyway, unless it is the main widget of the application.

    EDIT: Qt::FramelessWindowHint is a window flag and is meant to be used with QWidget::setWindowFlags.

    Regards

  7. The following 2 users say thank you to marcel for this useful post:

    swdev (10th June 2014), vonCZ (29th July 2007)

  8. #6
    Join Date
    Sep 2013
    Location
    Yogyakarta, Indonesia
    Posts
    3
    Thanks
    6
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: placing widgets on top of other widgets

    Wow! It really solve my case of trying to make floating search sheet in the current QWidgetTable.
    Previously I use layout and add things there: messy. The table unclickable.

    Using QFrame and use the table as the parent, solve this case very easily

    Thanks marcel!

Similar Threads

  1. Qt3 - Multiple transparent widgets
    By bythesea in forum Qt Programming
    Replies: 4
    Last Post: 11th September 2009, 12:24
  2. Performance in hiding/showing widgets
    By Paalrammer in forum Newbie
    Replies: 12
    Last Post: 14th February 2007, 19:57
  3. Replies: 11
    Last Post: 7th July 2006, 14:09
  4. Creating Widgets
    By hylke in forum Qt Programming
    Replies: 2
    Last Post: 5th February 2006, 09:37

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.