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. Styling of QLineEdit/QListView child of QCombobox on hover
Forum Update on Monday, May 27th 2025

Styling of QLineEdit/QListView child of QCombobox on hover

Scheduled Pinned Locked Moved Unsolved General and Desktop
qssqcomboboxqlineedit
3 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.
  • M Offline
    M Offline
    mikael.larsson
    wrote on 23 Jun 2020, 09:11 last edited by
    #1

    So I wanted a QComboBox with checkboxes and after seeing lots of problems with the normal implementation I found this when I searched
    https://stackoverflow.com/questions/8422760/combobox-of-checkboxes

    Especially this code:
    https://gist.github.com/mistic100/c3b7f3eabc65309687153fe3e0a9a720

    However, this has some limitations I don't know if it's possible to work around with styling which also is an important part of my project making it look just like the other comboboxes.

    The problem is my comboboxes uses padding and a background color on hover.

    QLineEdit:hover { background-color: red; }
    

    This would only work when my mouse is over the lineEdit and not the padded area leaving the QLineEdit with a white background when it's not over the exact QLineEdit

    So coming from CSS (which is absolutely superior to Qts styling btw) I tried this:

    QComboBox:hover QLineEdit { background-color: red; }
    

    But no change.

    Is there even a solution?

    Another problem would be that the selection-background-color of "QComboBox QAbstractView" doesn't work with this solution above and I'm not using any custom styled delegates yet.

    Hope you understand where I'm getting at.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mikael.larsson
      wrote on 7 Jul 2020, 09:35 last edited by mikael.larsson 7 Jul 2020, 09:48
      #2

      Still looking for help with this if its even possible this is how it looks on hover right now.
      Styling.png

      Even thinking about subclassing QLineEdit to force hover-effect but not sure how.

      M 1 Reply Last reply 7 Jul 2020, 11:45
      0
      • M mikael.larsson
        7 Jul 2020, 09:35

        Still looking for help with this if its even possible this is how it looks on hover right now.
        Styling.png

        Even thinking about subclassing QLineEdit to force hover-effect but not sure how.

        M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 7 Jul 2020, 11:45 last edited by
        #3

        @mikael-larsson
        Hi
        You could try an event filter on the Combobox and call the code for hover effect but
        if your effect is purely stylesheet based then i think you then must send it fake hover event to trigger it or something like that.

        You might also be able to subclass the combo and rig the paintEvent with
        if (someflag)
        option.state |= QStyle::State_MouseOver;

        to trigger hover on command from the event filter/ or combo hover or how you plan to trigger it.

        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