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. Do padding affect the tooltip ?
Qt 6.11 is out! See what's new in the release blog

Do padding affect the tooltip ?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 2.8k 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.
  • P Offline
    P Offline
    Pou Lin Chang
    wrote on last edited by
    #1

    class A : public QLineEdit
    {
    public:
    A()
    {
    setToolTip( "Some text here" );
    setStyleSheet("padding-top: -2px;");
    }
    }

    here when i hover my mouse on the QlineEdit, the tooltip text get cut off from bottom. But if i remove the padding the toolTip text displays it correctly.

    So does applying padding or any stylesheet affects the tooltip ??? I read in other forum that it's Qt bug.

    I would be glad if anyone can answer my queries. Thank you

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      It's not a bug per-se. Your style sheet is basically interpreted as. "Every widget and child widget has a top padding of -2px". If you only want your line edit to have that padding then you have to use a more precise style sheet.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • P Offline
        P Offline
        Pou Lin Chang
        wrote on last edited by Pou Lin Chang
        #3

        I get your point, but i am setting the stylesheet in the constructor of my class so wouldn't it be only for that class ?

        @SGaist

        mrjjM 1 Reply Last reply
        1
        • P Pou Lin Chang

          I get your point, but i am setting the stylesheet in the constructor of my class so wouldn't it be only for that class ?

          @SGaist

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Pou-Lin-Chang
          It would be for that class and all its children.

          Easy fix is to give class A object name and use that for style sheet
          then only that is affected.

          http://doc.qt.io/qt-5/stylesheet-syntax.html

          P 1 Reply Last reply
          3
          • mrjjM mrjj

            @Pou-Lin-Chang
            It would be for that class and all its children.

            Easy fix is to give class A object name and use that for style sheet
            then only that is affected.

            http://doc.qt.io/qt-5/stylesheet-syntax.html

            P Offline
            P Offline
            Pou Lin Chang
            wrote on last edited by
            #5

            @mrjj i applied this setStyleSheet( " QLineEdit{ padding-top : -2 } " )

            it worked. is it the right syntax ?

            mrjjM 1 Reply Last reply
            1
            • P Pou Lin Chang

              @mrjj i applied this setStyleSheet( " QLineEdit{ padding-top : -2 } " )

              it worked. is it the right syntax ?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Pou-Lin-Chang

              Yes its correct as it mean for all QLineEdits

              if you just want for sure on a single one.
              Give it a name (setObjectName(const QString & name))

              and use
              QPushButton#okButton { color: gray }

              here button is called okButton

              1 Reply Last reply
              1
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                To add to @mrjj, if you don't set any scope to your style sheet, it will apply to everything from that widget to all its children.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • P Offline
                  P Offline
                  Pou Lin Chang
                  wrote on last edited by
                  #8

                  @SGaist @mrjj thanks alot ^_^

                  1 Reply Last reply
                  1
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    You're welcome !

                    Since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    1

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved