PDA

View Full Version : placing widgets on top of other widgets



vonCZ
28th July 2007, 11:12
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?

marcel
28th July 2007, 13:40
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

vonCZ
28th July 2007, 14:46
thanks Marcel- i'm about to leave but will try it out on Monday.

vonCZ
29th July 2007, 12:34
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:


myInfoWidget->setFrameStyle(Qt::FramelessWindowHint);

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

marcel
29th July 2007, 12:45
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

swdev
10th June 2014, 10:21
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!