View Full Version : How to make a popup widget that looks like a popup?
Olivier Berten
3rd June 2010, 12:47
Popup widgets like menu and combo share a common look. How to give that look to a custom widget?
I tried reimplementing the paint event
def paintEvent(self, e):
p = QPainter(self)
option = QStyleOption()
option.initFrom(QMenu())
option.rect = self.rect()
self.style().drawPrimitive(QStyle.PE_FrameMenu, option, p, self)
self.style().drawPrimitive(QStyle.PE_PanelMenu, option, p, self)
But it isn't enough for styles like Oxygen or Bespin...
What am I missing?
Tondog
4th June 2010, 06:43
Why you don't use the window flags?
yourWidget->setWindowFlags(Qt::Popup)
Olivier Berten
4th June 2010, 06:49
I do, of course, but that just removes the frame...
aamer4yu
4th June 2010, 07:08
So what are you exactly trying to achieve ? the shadows ?
Olivier Berten
4th June 2010, 07:21
The similarity with other popups... whatever theme I use...
Concretely, what I miss in Bespin for instance is rounded corners and background image.
Tondog
4th June 2010, 09:35
For the background you can use the Qt Style Sheets.
expl:
QWidget{ background-image: url(:/yourImage.png) }
Olivier Berten
4th June 2010, 09:52
The problem is I want to make it style dependent (or independent, question of point of vue ;) )
I want it to have that fancy image with Bespin, that gradient with Oxygen and that flat gray with Cleanlooks.
Tondog
4th June 2010, 10:10
You can take the current style with QApplication::style () and then you can control what for a backroungimage you set.
Maybe we'll talk past each other :)
Olivier Berten
4th June 2010, 10:42
Then let's talk with pictures ;)
472447254726
Here is my widget and I want it to have the same look as the menu at the bottom of the picture.
Olivier Berten
6th June 2010, 13:19
Anybody? Any lead?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.