Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QComboBox styling is not dyamic
Qt 6.11 is out! See what's new in the release blog

QComboBox styling is not dyamic

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 705 Views 3 Watching
  • 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.
  • O Offline
    O Offline
    OwerPlay
    wrote on last edited by OwerPlay
    #1

    Hey!

    I am having a problem with QComboBox:

    1. I will show you a picture of my closed QComboBox
      a6389bbc-4c03-4368-aa2d-ed6bf771204a-image.png

    2. This is opened:
      08a829d6-09f9-4212-8242-a395cd611a75-image.png

    3. When closed again:
      6054e55b-42c2-4fd1-8f00-424bd979bc24-image.png

    4. When hovered:
      02754fb6-cecf-4e72-b7fd-10497d55cd92-image.png

    As you can see I have a problem of combobox now changing style on close, but staying in its "opened " style.

    Here is my combobox code:

      // Create filter combo box
      QComboBox *filterComboBox = new QComboBox();
      filterComboBox->addItem("All");
      filterComboBox->addItem("Errors");
      filterComboBox->addItem("Warnings");
      filterComboBox->addItem("Ok");
      filterComboBox->setFixedSize(250, 50);
    
      filterComboBox->setStyleSheet(
          "QComboBox {"
          "   border-radius: 10px;"
          "   background: qradialgradient(cx:0.5, cy:-0.3, radius:1.2, "
          "       fx:0.5, fy:0.0, stop:0 #555555, stop:1 #222222);"
          "   border: 2px solid #E67A4A;" /* Solid red border */
          "   padding: 5px;"
          "   color: white;"
          "   font-size: 16px;"
          "}"
    
          /* Remove the dropdown button */
          "QComboBox::drop-down {"
          "   border: none;"
          "   background: transparent;"
          "   width: 0px;"
          "}"
    
          /* Dropdown menu styling */
          "QComboBox QAbstractItemView {"
          "   background: qradialgradient(cx:0.5, cy:1.3, radius:1.2, "
          "       fx:0.5, fy:1.0, stop:0 #555555, stop:1 #222222);"
          "   color: white;"
          "   border-top: 0px;"
          "   border-left: 2px solid #E67A4A;"
          "   border-right: 2px solid #E67A4A;"
          "   border-bottom: 2px solid #E67A4A;"
          "   padding: 5px;"
          "   border-bottom-left-radius: 10px;"
          "   border-bottom-right-radius: 10px;"
          "}"
    
          /* When the dropdown is open */
          "QComboBox:open {"
          "   border-top-left-radius: 10px;"
          "   border-top-right-radius: 10px;"
          "   border-bottom-left-radius: 0px;"
          "   border-bottom-right-radius: 0px;"
          "   border-top: 2px solid #E67A4A;"
          "   border-left: 2px solid #E67A4A;"
          "   border-right: 2px solid #E67A4A;"
          "   border-bottom: 0px;"
          "}");
    
      hbox->addWidget(filterComboBox);
    

    Thank you in advance!

    Qt version: 6.6.2

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Which OS are you on ?
      With 6.7.2 on macOS 14.7 I don't have the issue you describe however the position of the drop down is different when opened.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      O 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Which OS are you on ?
        With 6.7.2 on macOS 14.7 I don't have the issue you describe however the position of the drop down is different when opened.

        O Offline
        O Offline
        OwerPlay
        wrote on last edited by
        #3

        @SGaist I am on windows.

        1 Reply Last reply
        0

        • Login

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