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. QT6: QComboBox focus style
Forum Update on Monday, May 27th 2025

QT6: QComboBox focus style

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 272 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.
  • T Offline
    T Offline
    Terry Barnaby
    wrote on last edited by
    #1

    I am trying to set the style of a QComboBox when it is in focus (tabbed to).
    The general QComboBox style is a black background with white text.

    When I try the following styles, when the QComboBox is in focus its background does change to white, but the text stays white.

    QComboBox {
    background-color: black;
    color: white;
    }
    QComboBox:focus {
    background-color: white;
    color: black;
    }

    I have also tried:
    QComboBox:selected {
    background-color: white;
    color: black;
    }
    This seems to work like the :focus.

    1. How do I set the text color when in focus ?
    2. Is there a definitive guide to all Qt style options (There appear only to be a few examples) ?
    jsulmJ 1 Reply Last reply
    0
    • T Terry Barnaby

      I am trying to set the style of a QComboBox when it is in focus (tabbed to).
      The general QComboBox style is a black background with white text.

      When I try the following styles, when the QComboBox is in focus its background does change to white, but the text stays white.

      QComboBox {
      background-color: black;
      color: white;
      }
      QComboBox:focus {
      background-color: white;
      color: black;
      }

      I have also tried:
      QComboBox:selected {
      background-color: white;
      color: black;
      }
      This seems to work like the :focus.

      1. How do I set the text color when in focus ?
      2. Is there a definitive guide to all Qt style options (There appear only to be a few examples) ?
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Terry-Barnaby https://doc.qt.io/qt-6/stylesheet-syntax.html
      https://doc.qt.io/qt-6/stylesheet-reference.html

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

      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