Results 1 to 10 of 10

Thread: How to make a popup widget that looks like a popup?

  1. #1
    Join Date
    Sep 2009
    Posts
    19
    Qt products
    Platforms
    Unix/X11

    Default How to make a popup widget that looks like a popup?

    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
    Qt Code:
    1. def paintEvent(self, e):
    2. p = QPainter(self)
    3. option = QStyleOption()
    4. option.initFrom(QMenu())
    5. option.rect = self.rect()
    6. self.style().drawPrimitive(QStyle.PE_FrameMenu, option, p, self)
    7. self.style().drawPrimitive(QStyle.PE_PanelMenu, option, p, self)
    To copy to clipboard, switch view to plain text mode 
    But it isn't enough for styles like Oxygen or Bespin...

    What am I missing?

  2. #2
    Join Date
    Jul 2009
    Location
    Switzerland
    Posts
    15
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to make a popup widget that looks like a popup?

    Why you don't use the window flags?

    Qt Code:
    1. yourWidget->setWindowFlags(Qt::Popup)
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2009
    Posts
    19
    Qt products
    Platforms
    Unix/X11

    Default Re: How to make a popup widget that looks like a popup?

    I do, of course, but that just removes the frame...

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to make a popup widget that looks like a popup?

    So what are you exactly trying to achieve ? the shadows ?

  5. #5
    Join Date
    Sep 2009
    Posts
    19
    Qt products
    Platforms
    Unix/X11

    Default Re: How to make a popup widget that looks like a popup?

    The similarity with other popups... whatever theme I use...

    Concretely, what I miss in Bespin for instance is rounded corners and background image.

  6. #6
    Join Date
    Jul 2009
    Location
    Switzerland
    Posts
    15
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to make a popup widget that looks like a popup?

    For the background you can use the Qt Style Sheets.

    expl:

    Qt Code:
    1. QWidget{ background-image: url(:/yourImage.png) }
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Sep 2009
    Posts
    19
    Qt products
    Platforms
    Unix/X11

    Default Re: How to make a popup widget that looks like a popup?

    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.

  8. #8
    Join Date
    Jul 2009
    Location
    Switzerland
    Posts
    15
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to make a popup widget that looks like a popup?

    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

  9. #9
    Join Date
    Sep 2009
    Posts
    19
    Qt products
    Platforms
    Unix/X11

    Default Re: How to make a popup widget that looks like a popup?

    Then let's talk with pictures

    popup-Oxygen..pngpopup-Bespin..pngpopup-Cleanlooks&#4.png

    Here is my widget and I want it to have the same look as the menu at the bottom of the picture.

  10. #10
    Join Date
    Sep 2009
    Posts
    19
    Qt products
    Platforms
    Unix/X11

    Default Re: How to make a popup widget that looks like a popup?

    Anybody? Any lead?

Similar Threads

  1. Replies: 7
    Last Post: 18th May 2010, 13:49
  2. A popup widget in QDialog.
    By Alex_123 in forum Qt Programming
    Replies: 1
    Last Post: 11th June 2009, 16:25
  3. Replies: 3
    Last Post: 17th May 2009, 21:17
  4. Make the QComboBox popup translucent or transparent ?
    By charlse in forum Qt Programming
    Replies: 5
    Last Post: 18th August 2008, 17:18
  5. Sliding popup widget
    By momesana in forum Qt Programming
    Replies: 7
    Last Post: 19th September 2007, 23:30

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.