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 with static image
QtWS25 Last Chance

QComboBox with static image

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.5k 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.
  • R Offline
    R Offline
    redlars
    wrote on last edited by
    #1

    Hello,

    The QComboBox will when not in focus show the currently selected item using text and possibly an icon. How can I override this behaviour to show a static image when the ComboBox is not in focus. This is to reduce the space the button takes up. The perfect example is in Windows Explorer, there is a comboBox for View. The ComboBox just contains a simple generic icon but does not say anything about the selected view. Clicking on the button will show the four choices with dot infront of the selected choice.

    How can this be done in Qt?

    Cheers

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      You might want to check out the type of events that Qt can handle. For the given widget you might want to use this one:
      @QEvent::FocusOut 9 Widget loses keyboard focus (QFocusEvent).@
      Then in that event set the value to the one with the icon only to display. Tada, should work
      Greetz

      Greetz, Jeroen

      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