Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to adjust QComboBox?



  • Hi, I want to adjust my QCombobox and its items to have a look that is identical to buttons on the left. In short, this combobox should have a circular shape and a size of QSize(50,50), but I am not sure how to do it. The picture attached is to provide greater details on what I want to achieve. Any help will be very welcome.
    a22d6d5b-1c1f-408a-a7d5-fe9f4a2031d7-image.png



  • Thank you. I figure out that I mis-spell QComboBox in the stylesheet and that is main cause of the problem. Eventually, I get the result that I want and this is the code that provides it.
    d52b79c6-4db5-4a5b-b91b-aa79fddbac29-image.png

        ui -> comboBox -> setStyleSheet(
                    "QComboBox{"
                        "background-color: rgb(238,238,238);"
                        "border: 1px solid black;"
                        "border-radius: 25px;"
                        "width: 40;"
                        "height: 50;"
                    "}"
                    "QComboBox::drop-down{"
                        "border-width: 0px;"
                        "margin-left: 0px;"
                     "}"
                    "QComboBox::down-arrow{"
                        "image:url(://Button_Icons/down-arrow.png);"
                        "width: 10px;"
                        "height: 50px;"
                    "}");
    

  • Lifetime Qt Champion



  • Hi, I've read through the document and write this stylesheet up. But nothing has changed. The combobox still looks exactly the same.

     ui -> comboBox -> setStyleSheet(
                    "QComboBox::drop-down{"
                        "subcontrol-position: top right;"
                        "width: 0px;"
                        "border-left-width: 0px;"
                        "border-left-color: none;"
                        "border-left-style: transparent;" 
                        "border-top-right-radius: 0px;" 
                        "border-bottom-right-radius: 0px;"
                     "}"
                    "QCombobox{"
                        "border: 1px solid black;"
                        "border-radius:3px;"
                        "border-color:black;"
                        "border-width: 25 25;"
                    "}");
    


  • Thank you. I figure out that I mis-spell QComboBox in the stylesheet and that is main cause of the problem. Eventually, I get the result that I want and this is the code that provides it.
    d52b79c6-4db5-4a5b-b91b-aa79fddbac29-image.png

        ui -> comboBox -> setStyleSheet(
                    "QComboBox{"
                        "background-color: rgb(238,238,238);"
                        "border: 1px solid black;"
                        "border-radius: 25px;"
                        "width: 40;"
                        "height: 50;"
                    "}"
                    "QComboBox::drop-down{"
                        "border-width: 0px;"
                        "margin-left: 0px;"
                     "}"
                    "QComboBox::down-arrow{"
                        "image:url(://Button_Icons/down-arrow.png);"
                        "width: 10px;"
                        "height: 50px;"
                    "}");
    

Log in to reply