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. Focus on QLabel twitches text
Forum Updated to NodeBB v4.3 + New Features

Focus on QLabel twitches text

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 2.2k 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.
  • A Offline
    A Offline
    AlaaM
    wrote on last edited by AlaaM
    #1

    Whenever there's focus on a QLabel, the text inside twitches a little to the bottom. Take a look at this picture:
    http://i90.photobucket.com/albums/k274/alaa_137/qlabel_zps3aheyglu.png
    Here every digit is a separate QLabel.
    Notice that the first digit on the left is twitched a little to the bottom because it has focus. Also when I move focus to another digit, then the 1st digit is still twitched, and the newly focused digit gets twitched as well.

    Why is this happening? Can I disable this?

    Thanks

    raven-worxR 1 Reply Last reply
    0
    • A AlaaM

      Whenever there's focus on a QLabel, the text inside twitches a little to the bottom. Take a look at this picture:
      http://i90.photobucket.com/albums/k274/alaa_137/qlabel_zps3aheyglu.png
      Here every digit is a separate QLabel.
      Notice that the first digit on the left is twitched a little to the bottom because it has focus. Also when I move focus to another digit, then the 1st digit is still twitched, and the newly focused digit gets twitched as well.

      Why is this happening? Can I disable this?

      Thanks

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @AlaaM
      Operating system?
      Qt version?
      Using stylesheets or anything?
      Any interaction with the widget's QStyle?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AlaaM
        wrote on last edited by AlaaM
        #3

        Operating system: Ubuntu 14.04
        Qt 5.5.1
        Was using the following stylesheet:

        QString("QLabel:focus{"
                     "outline: 0;"
                     "background-color: #" BACKGROUND  "; "
                     "color: #"            FOREGROUND  "; "
                 "} "
        ) 
        

        But seems that the issue happens with and without it.

        Nothing with the widget's QStyle

        raven-worxR 1 Reply Last reply
        0
        • A AlaaM

          Operating system: Ubuntu 14.04
          Qt 5.5.1
          Was using the following stylesheet:

          QString("QLabel:focus{"
                       "outline: 0;"
                       "background-color: #" BACKGROUND  "; "
                       "color: #"            FOREGROUND  "; "
                   "} "
          ) 
          

          But seems that the issue happens with and without it.

          Nothing with the widget's QStyle

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @AlaaM
          Did you build Qt yourself?
          have you changed anything regarding HARFBUZZ?

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • A Offline
            A Offline
            AlaaM
            wrote on last edited by AlaaM
            #5

            @raven-worx I did not build Qt myself. I downloaded QtCreator and Qt libraries.
            I don't know what HARFBUZZ is so I guess I didn't change it.

            I don't think this has something to do with the compilation...

            I think it's either Ubuntu's default, or something in my code.
            I can try to change the QLabel to something else (say QTextEdit) and see what happens.

            raven-worxR 1 Reply Last reply
            0
            • E Offline
              E Offline
              elveatles
              wrote on last edited by
              #6

              Does it still twitch if you don't use the stylesheet?

              1 Reply Last reply
              0
              • A Offline
                A Offline
                AlaaM
                wrote on last edited by
                #7

                @elveatles Yes. As I said: seems that the issue happens with and without it.

                1 Reply Last reply
                0
                • A AlaaM

                  @raven-worx I did not build Qt myself. I downloaded QtCreator and Qt libraries.
                  I don't know what HARFBUZZ is so I guess I didn't change it.

                  I don't think this has something to do with the compilation...

                  I think it's either Ubuntu's default, or something in my code.
                  I can try to change the QLabel to something else (say QTextEdit) and see what happens.

                  raven-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by
                  #8

                  @AlaaM said:

                  I don't know what HARFBUZZ is so I guess I didn't change it.

                  HARFBUZZ is used for text rendering in Qt.
                  But i do not know if on Ubuntu (or in general in Linux) the system lib is used or the built-in version of Qt is used by default.

                  Maybe someone else can confirm/disprove this?

                  But updating the harfbuzz lib on your system is worth a shot i guess.

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    AlaaM
                    wrote on last edited by AlaaM
                    #9

                    I can't believe I didn't think of this before. Here's the solution:

                    labels[i]->setStyleSheet(QString("QLabel{"
                                                         "padding: 0px"
                                                     "}"
                                                    )
                                             );
                    

                    (or any other number for padding)

                    This disables the twitching.

                    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