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. I am trying to set tooltip display width with the following code but i am not getting the exact output?
Forum Update on Monday, May 27th 2025

I am trying to set tooltip display width with the following code but i am not getting the exact output?

Scheduled Pinned Locked Moved General and Desktop
13 Posts 4 Posters 12.1k 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.
  • P Offline
    P Offline
    pratik041
    wrote on 12 Jan 2012, 11:48 last edited by
    #1

    @ wid.setStyleSheet("QToolTip {font-size:12pt; color:white; border-width:2px; border-style:solid; width: 10px;}");@
    What is the error in the above code?

    Pratik Agrawal

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stima_ua
      wrote on 12 Jan 2012, 12:19 last edited by
      #2

      http://developer.qt.nokia.com/doc/qt-4.8/stylesheet-reference.html search width.

      @wid.setStyleSheet("QToolTip {font-size:12pt; color:white; border 2px solid black; min-width: 10px;}");@

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on 12 Jan 2012, 12:36 last edited by
        #3

        [quote author="pratik041" date="1326368889"]@ wid.setStyleSheet("QToolTip {font-size:12pt; color:white; border-width:2px; border-style:solid; width: 10px;}");@
        What is the error in the above code?[/quote]

        Well - that's the question: what is the error in the code above.

        So, what is the error in the code above? Which result do you expect? Which result do you get instead?

        1 Reply Last reply
        0
        • P Offline
          P Offline
          pratik041
          wrote on 12 Jan 2012, 12:37 last edited by
          #4

          i have tried this i am now getting the require width but another problem is their the tooltip text
          is not visible.
          i have used the following
          @wid.setStyleSheet("QToolTip {font-size:12pt; color:white; border 2px solid black; min-width: 10px;}");
          wid.settooltip("text");@

          Pratik Agrawal

          1 Reply Last reply
          0
          • P Offline
            P Offline
            pratik041
            wrote on 12 Jan 2012, 12:43 last edited by
            #5

            [quote author="Lukas Geyer" date="1326371764"][quote author="pratik041" date="1326368889"]@ wid.setStyleSheet("QToolTip {font-size:12pt; color:white; border-width:2px; border-style:solid; width: 10px;}");@
            What is the error in the above code?[/quote]

            Well - that's the question: what is the error in the code above.

            So, what is the error in the code above? Which result do you expect? Which result do you get instead?[/quote]

            First thing is i want to set tooltip display rect to given width like if i set 40px width if the tooltip text exceeds the 40px it should display in the next line.
            Secondly the error is i am not getting the width i set and the tooltip is also not showing only the blank tooltip rect is coming.

            Pratik Agrawal

            1 Reply Last reply
            0
            • S Offline
              S Offline
              stima_ua
              wrote on 12 Jan 2012, 12:43 last edited by
              #6

              @QToolTip {
              font-size:12pt;
              color:white; --- Font color ----<<<< Attention!! use (pseudo code) background: ~white or color: ~white
              border 2px solid black; --- border width, style, color
              min-width: 10px;
              @

              1 Reply Last reply
              0
              • P Offline
                P Offline
                pratik041
                wrote on 12 Jan 2012, 13:14 last edited by
                #7

                [quote author="stima_ua" date="1326372218"]@QToolTip {
                font-size:12pt;
                color:white; --- Font color ----<<<< Attention!! use (pseudo code) background: ~white or color: ~white
                border 2px solid black; --- border width, style, color
                min-width: 10px;
                @[/quote]

                but setting pseduo code the tooltip is displaying but width portion is not working i am using "max-width" instead of "min-width".

                Pratik Agrawal

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  stima_ua
                  wrote on 12 Jan 2012, 13:25 last edited by
                  #8

                  @QString text = "Some text: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"@ --- its 1 line

                  You want:

                  .
                  | Some text: aaaa |
                  .
                  | aaaaaaaaaaaaaa |

                  You need:
                  (pseudo code)

                  @if ( text.size() > mySize ) {
                  text.insert(mySize, "\n")
                  }@

                  Something like this.

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    pratik041
                    wrote on 12 Jan 2012, 13:43 last edited by
                    #9

                    [quote author="stima_ua" date="1326374757"]@QString text = "Some text: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"@ --- its 1 line

                    You want:

                    .
                    | Some text: aaaa |
                    .
                    | aaaaaaaaaaaaaa |

                    You need:
                    (pseudo code)

                    @if ( text.size() > mySize ) {
                    text.insert(mySize, "\n")
                    }@

                    Something like this.[/quote]

                    ya i want like this. Is it possible through stylesheet?
                    I can do this by inserting "\n" in the tooltip string but the problem is that i want to break string according to pixels width.Do you have any way for doing this?

                    Pratik Agrawal

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      stima_ua
                      wrote on 12 Jan 2012, 13:52 last edited by
                      #10

                      hm...i think its possible, but i dont know how((;

                      p.s. If you find solution post him plz

                      p.s.s. mb use QTextLayout ... sorry but i have not time to test))

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        pratik041
                        wrote on 12 Jan 2012, 13:59 last edited by
                        #11

                        [quote author="stima_ua" date="1326376375"]hm...i think its possible, but i dont know how((;

                        p.s. If you find solution post him plz[/quote]

                        I have tried using QfontMetrices . Here i am able to find the total text pixel size but i don't able to find how to break it according to pixels size.

                        Pratik Agrawal

                        1 Reply Last reply
                        0
                        • J Offline
                          J Offline
                          joonhwan
                          wrote on 12 Jan 2012, 22:02 last edited by
                          #12

                          After reading this post, I checked Qt doc and found.

                          bq. Rich text displayed in a tool tip is implicitly word-wrapped unless specified differently with <p >.

                          Hmm.. if your text is not wrapped, what was the problem then? wierd.

                          joonhwan at gmail dot com

                          1 Reply Last reply
                          0
                          • P Offline
                            P Offline
                            pratik041
                            wrote on 13 Jan 2012, 04:44 last edited by
                            #13

                            [quote author="joonhwan" date="1326405736"]After reading this post, I checked Qt doc and found.

                            bq. Rich text displayed in a tool tip is implicitly word-wrapped unless specified differently with <p >.

                            Hmm.. if your text is not wrapped, what was the problem then? wierd.[/quote]

                            I want to write a function where i will provide required text width in pixels and that function will set the tooltip display width to specified pixels width and the line exceeding it will be come to the next line.Can you say me what useful information you found in the doc related to this and How can i use that to achieve this with some example?

                            Pratik Agrawal

                            1 Reply Last reply
                            0

                            4/13

                            12 Jan 2012, 12:37

                            9 unread
                            • Login

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