Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved How to adjust QComboBox?

    Qt 6
    2
    4
    492
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      Christina123 last edited by

      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

      jsulm 1 Reply Last reply Reply Quote 0
      • C
        Christina123 last edited by

        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;"
                        "}");
        
        1 Reply Last reply Reply Quote 2
        • jsulm
          jsulm Lifetime Qt Champion @Christina123 last edited by

          @Christina123 https://doc.qt.io/qt-5/stylesheet-reference.html
          https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qcombobox

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply Reply Quote 0
          • C
            Christina123 last edited by

            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;"
                            "}");
            
            1 Reply Last reply Reply Quote 0
            • C
              Christina123 last edited by

              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;"
                              "}");
              
              1 Reply Last reply Reply Quote 2
              • First post
                Last post