Results 1 to 4 of 4

Thread: [QComboBox] problem with popup position

  1. #1
    Join Date
    Feb 2010
    Posts
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows

    Default [QComboBox] problem with popup position

    Hi everyone,

    I'm currently working with the QGraphicsView framework and I'm embedding some widget in a scene where some graph drawing is done.
    My embedded widget is meant to be a quick access bar anchored to the bottom of the scene. I added a QGraphicsProxyWidget to my scene and I move it to the bottom of the scene every time the QGraphicsView widget gets resized.
    Everything worked perfectly until I decided to add a QComboBox in my bottom bar. When I click on the combo label, the popup always shows up at the bottom of the QComboBox. Except it should be displayed on top of the combo box since my widget is located at the very bottom of my application. Here's a screenshot of what happens:

    qcombobox_problem.png
    Note: The red square shows the actual area on which the popup is expanded.

    So my question is: Is there a way to force the QComboBox's popup position either by subclassing QComboBox or with some stylesheet configuration ?

    I checked the QComboBox::showPopup() method already but reimplementing it would mean re-writing all the code concerning the actual creation of the popup widget and I'd rather avoid that.

    Any suggestion ?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: [QComboBox] problem with popup position

    Quote Originally Posted by Auliyaa View Post
    So my question is: Is there a way to force the QComboBox's popup position either by subclassing QComboBox or with some stylesheet configuration ?
    Widgets in GraphicsView are inherently broken when it comes to respecting your desktop. If you subclass you should be able to make it work however it is hard to say how much work needs to be done.

    I checked the QComboBox::showPopup() method already but reimplementing it would mean re-writing all the code concerning the actual creation of the popup widget and I'd rather avoid that.
    It's not that bad. The popup is there, you just need to access it. Either look in Qt source code to see how it is called and use qFindChild() or try your luck with calling view()->parent().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2010
    Posts
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [QComboBox] problem with popup position

    Thanks for your reply ^^

    The QComboBox's popup is located in the d pointer of the combo box. Which means that you need to use the Qt private headers to be able to use it. Unfortunately, we cannot force such a dependency into our software. I think I'm just going to provide my own popup to control position.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: [QComboBox] problem with popup position

    Quote Originally Posted by Auliyaa View Post
    The QComboBox's popup is located in the d pointer of the combo box. Which means that you need to use the Qt private headers to be able to use it.
    No, that's not true. The widget is a child of the combobox and not the "d" pointer since the latter is not a QObject so regardless where it is stored, you can access it using qFindChild().

    Qt Code:
    1. QWidget *popup = comboBox->findChild<QFrame*>(); // here is your popup
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QComboBox Popup position
    By alitoh in forum Qt Programming
    Replies: 1
    Last Post: 25th November 2011, 11:16
  2. how to set popup window at the different position
    By xiongxiongchuan in forum Qt Programming
    Replies: 1
    Last Post: 18th April 2011, 09:07
  3. Replies: 3
    Last Post: 17th May 2009, 21:17
  4. QComboBox popup
    By aekilic in forum Qt Programming
    Replies: 9
    Last Post: 6th January 2009, 11:24
  5. Position of Qt::WindowFlags / Qt::Popup
    By patrik08 in forum Qt Programming
    Replies: 3
    Last Post: 3rd July 2006, 16:44

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.