Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-113599

QCombobox background color is faded

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.5.0
    • Widgets: Style Sheets
    • None
    • Ubuntu 22.04
    • Linux/Wayland

    Description

      Applying a background colour to a QCombox will result in fading.

       

      Let us consider this code:

      CMakeLists.txt

       

      cmake_minimum_required(VERSION 3.5)
      project(QCombobox LANGUAGES CXX)
      set(CMAKE_INCLUDE_CURRENT_DIR ON)
      set(CMAKE_AUTOUIC ON)
      set(CMAKE_AUTOMOC ON)
      set(CMAKE_AUTORCC ON)
      set(CMAKE_CXX_STANDARD 17)
      set(CMAKE_CXX_STANDARD_REQUIRED ON)
      find_package(Qt6 COMPONENTS REQUIRED Core Widgets)
      set(SOURCE_FILES
        main.cpp
        )
      add_executable(QCombobox ${SOURCE_FILES})
      target_link_libraries(QCombobox PRIVATE
        Qt6::Core
        Qt6::Widgets)
      

       

      main.cpp

       

      #include <QApplication>
      #include <QComboBox>
      int main(int argc,char*argv[]){
        QApplication a(argc, argv);
        QComboBox b;
        b.addItem("a");
        b.setStyleSheet("background: red;");
        b.show();
        return a.exec();
      }
      

       

      It renders as:

      It not the same as the "real" red colour that I get when I click on the QComboBox:

       

      Note: the colour is not faded if setFlat() is true

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            delaune Olivier Delaune
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes