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. QLineEdit:hover { background: blue; } only changes color when it has focus

QLineEdit:hover { background: blue; } only changes color when it has focus

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 778 Views 2 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.
  • M Offline
    M Offline
    Mighty_Pig
    wrote on last edited by Mighty_Pig
    #1

    So my application has multiple QLineEdit widgets. These widgets are created inside my own custom class, which is derived from QWidget.
    The constructor of my custom class is as following:

    setFixedSize(200,50);
    setAutoFillBackground(true);
    inputLine->setValidator(validator);
    inputLine->setMinimumSize(100,30);
    inputLine->setToolTip("hovering");
    inputLine->setStyleSheet("QLineEdit:hover { background: blue; } QLineEdit { background: green;}");
    

    Inside the header file, the QLineEdit is created as following:

    QLineEdit *inputLine = new QLineEdit(this);
    

    I would expect the inputLine to be green and when the mouse is hovering over the widget to turn blue, however this does not happen.
    alt text

    Also, the tooltip is also not appearing.
    However, if I put focus onto one of the QLineEdit by clicking on it, it does give the tool tip and also turns the background to blue. Once I clicked one of the QLineEdit's it will give you the tooltip when hovering over other lines too.
    alt text

    Either this is a bug or I am not understanding how the QLineEdit:hover pseudo state works?

    Any help will be appreciated.

    Edit 1:

    I came across QLineEdit. So I went to try this instead of QLineEdit and this is the result.
    alt text
    And this just works as I expected it to work with QLineEdit, so this makes me think even more it's a bug. Although this is a working alternative for me since I will mostly use it for numbers anyway, I am still not satisfied with why it's not working with QLineEdit.

    M 1 Reply Last reply
    0
    • M Offline
      M Offline
      Mighty_Pig
      wrote on last edited by
      #2

      So I just tested it on Linux and on Linux the QLineEdit works the same as QSpinBox. So I guess its a bug for windows.

      Christian EhrlicherC 1 Reply Last reply
      0
      • M Mighty_Pig

        So I just tested it on Linux and on Linux the QLineEdit works the same as QSpinBox. So I guess its a bug for windows.

        Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        What exact Qt version and style do you use on windows?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        M 1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          What exact Qt version and style do you use on windows?

          M Offline
          M Offline
          Mighty_Pig
          wrote on last edited by Mighty_Pig
          #4

          @Christian-Ehrlicher Hey, I use windows 11 and QT version 6.7.0. The style version I am not sure but its the latest stable.

          1 Reply Last reply
          0
          • M Mighty_Pig

            So my application has multiple QLineEdit widgets. These widgets are created inside my own custom class, which is derived from QWidget.
            The constructor of my custom class is as following:

            setFixedSize(200,50);
            setAutoFillBackground(true);
            inputLine->setValidator(validator);
            inputLine->setMinimumSize(100,30);
            inputLine->setToolTip("hovering");
            inputLine->setStyleSheet("QLineEdit:hover { background: blue; } QLineEdit { background: green;}");
            

            Inside the header file, the QLineEdit is created as following:

            QLineEdit *inputLine = new QLineEdit(this);
            

            I would expect the inputLine to be green and when the mouse is hovering over the widget to turn blue, however this does not happen.
            alt text

            Also, the tooltip is also not appearing.
            However, if I put focus onto one of the QLineEdit by clicking on it, it does give the tool tip and also turns the background to blue. Once I clicked one of the QLineEdit's it will give you the tooltip when hovering over other lines too.
            alt text

            Either this is a bug or I am not understanding how the QLineEdit:hover pseudo state works?

            Any help will be appreciated.

            Edit 1:

            I came across QLineEdit. So I went to try this instead of QLineEdit and this is the result.
            alt text
            And this just works as I expected it to work with QLineEdit, so this makes me think even more it's a bug. Although this is a working alternative for me since I will mostly use it for numbers anyway, I am still not satisfied with why it's not working with QLineEdit.

            M Offline
            M Offline
            Mighty_Pig
            wrote on last edited by
            #5

            @Mighty_Pig said in QLineEdit:hover { background: blue; } only changes color when it has focus:

            QLineEdit

            Correction: I came across QSpinBox not QLineEdit

            Christian EhrlicherC 1 Reply Last reply
            0
            • M Mighty_Pig

              @Mighty_Pig said in QLineEdit:hover { background: blue; } only changes color when it has focus:

              QLineEdit

              Correction: I came across QSpinBox not QLineEdit

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Start your app with -style windowsvista to use the windows 10 style instead the new windows 11 style which is new in qt6.7 and still has some problems. Pinging @Axel-Spoerl to see if this bug is already reported and maybe fixed.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              Axel SpoerlA 1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                Start your app with -style windowsvista to use the windows 10 style instead the new windows 11 style which is new in qt6.7 and still has some problems. Pinging @Axel-Spoerl to see if this bug is already reported and maybe fixed.

                Axel SpoerlA Offline
                Axel SpoerlA Offline
                Axel Spoerl
                Moderators
                wrote on last edited by
                #7

                @Christian-Ehrlicher
                Doesn’t ring a bell here. Maybe worth reporting!

                Software Engineer
                The Qt Company, Oslo

                M 1 Reply Last reply
                0
                • Axel SpoerlA Axel Spoerl

                  @Christian-Ehrlicher
                  Doesn’t ring a bell here. Maybe worth reporting!

                  M Offline
                  M Offline
                  Mighty_Pig
                  wrote on last edited by
                  #8

                  @Axel-Spoerl I already made a bug report.
                  https://bugreports.qt.io/browse/QTBUG-124549

                  Axel SpoerlA 1 Reply Last reply
                  0
                  • M Mighty_Pig

                    @Axel-Spoerl I already made a bug report.
                    https://bugreports.qt.io/browse/QTBUG-124549

                    Axel SpoerlA Offline
                    Axel SpoerlA Offline
                    Axel Spoerl
                    Moderators
                    wrote on last edited by
                    #9

                    @Mighty_Pig
                    Very well, I’ll look into it then.

                    Software Engineer
                    The Qt Company, Oslo

                    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