Results 1 to 2 of 2

Thread: QComboBox popup arrows [Mac OS X]

  1. #1
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 26 Times in 23 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default QComboBox popup arrows [Mac OS X]

    I have noticed some strange behavior when applied the stylesheet to QComboBox on Mac OS X: changing properties like margin or padding produces arrows for the popup. Here is the code:

    Qt Code:
    1. #include <QVBoxLayout>
    2. #include <QLineEdit>
    3. #include "mainwindow.h"
    4.  
    5. MainWindow::MainWindow(): QMainWindow()
    6. {
    7. QFrame *frame = new QFrame;
    8.  
    9. this->cbo1 = new QComboBox;
    10. this->setObjectName("cbo1");
    11.  
    12. this->cbo2 = new QComboBox;
    13. this->cbo2->setObjectName("cbo2");
    14.  
    15. this->cbo3 = new QComboBox;
    16. this->cbo3->setObjectName("cbo3");
    17.  
    18. for (int i = 0; i < 10; ++i)
    19. {
    20. this->cbo1->addItem("item " + QString::number(i));
    21. this->cbo2->addItem("item " + QString::number(i));
    22. this->cbo3->addItem("item " + QString::number(i));
    23. }
    24.  
    25. QVBoxLayout *layout = new QVBoxLayout(frame);
    26. layout->addWidget(this->cbo1);
    27. layout->addWidget(this->cbo2);
    28. layout->addWidget(this->cbo3);
    29.  
    30. setCentralWidget(frame);
    31. }
    32.  
    33. MainWindow::~MainWindow()
    34. {
    35. }
    To copy to clipboard, switch view to plain text mode 

    There are three comboboxes: cbo1, cbo2, cbo3. For cbo1 I didn't change neither margin nor padding, for cbo2 I changed margin-bottom and for cbo3 I changed padding-left. The stylesheet is shown below:
    Qt Code:
    1. {
    2. background-color: red;
    3. }
    4.  
    5. QComboBox#cbo2
    6. {
    7. background-color: yellow;
    8. /*margin-left: 5px;*/
    9. margin-bottom: 2px;
    10. }
    11.  
    12. QComboBox#cbo2 QAbstractItemView
    13. {
    14. background-color: yellow;
    15. margin-top: 0px;
    16. padding-top: 0px;
    17. margin-bottom: 0px;
    18. padding-bottom: 0px;
    19. background-clip: margin;
    20. outline: none;
    21. }
    22.  
    23. QComboBox#cbo3
    24. {
    25. background-color: #c0c0c0;
    26. padding-left: 5px;
    27. }
    To copy to clipboard, switch view to plain text mode 

    It looks like this:
    normal.png(cbo1)margin.png(cbo2)padding.png(cbo3)

    As you can see, cbo2 and cbo3 have some strange arrows in their popup. Is it possible to prevent this or change appearance of those arrows so they better fit to the control style?

  2. #2
    Join Date
    Dec 2011
    Posts
    36
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QComboBox popup arrows [Mac OS X]

    This is a Mac OS issue. I read about a work around somewhere. I recall manipulating the position of the arrow so it goes off screen, and or not setting the current item... I have no mac Os so I can't test it for you.

Similar Threads

  1. QComboBox popup
    By berchio in forum Qt Programming
    Replies: 0
    Last Post: 25th October 2012, 20:05
  2. QComboBox Popup position
    By alitoh in forum Qt Programming
    Replies: 1
    Last Post: 25th November 2011, 10:16
  3. Related to Popup of the QComboBox
    By ashishsaryar in forum Qt Programming
    Replies: 1
    Last Post: 10th July 2009, 16:29
  4. popup QKeyEvent in QComboBox
    By olosie in forum Qt Programming
    Replies: 2
    Last Post: 25th April 2009, 09:24
  5. QComboBox popup
    By aekilic in forum Qt Programming
    Replies: 9
    Last Post: 6th January 2009, 10:24

Tags for this Thread

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.