Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. How to adjust QComboBox?
QtWS25 Last Chance

How to adjust QComboBox?

Scheduled Pinned Locked Moved Solved Qt 6
4 Posts 2 Posters 1.0k Views
  • 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 Offline
    C Offline
    Christina123
    wrote on last edited by
    #1

    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

    jsulmJ 1 Reply Last reply
    0
    • C Offline
      C Offline
      Christina123
      wrote on last edited by
      #4

      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
      2
      • C Christina123

        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

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @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
        0
        • C Offline
          C Offline
          Christina123
          wrote on last edited by
          #3

          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
          0
          • C Offline
            C Offline
            Christina123
            wrote on last edited by
            #4

            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
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved