Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-105939

QToolTip works incorrectly, when it is limited by width.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 5.15.2
    • None
    • Windows 10, but debugging the code, I am sure it can be reproduced on any platform.
    • Windows

      I have a qss with specified max-width: 

      QToolTip { max-width: 300px; }

       

      If the tooltip-text is short or consist of multiple short lines - it works fine. But once it get bigger, and occupy more lines, it does not extend the height of the tooltip properly.

      To illustrate the problem, I will use Qt designer, as the issue easily reproducable there:

      It is default tooltip-size (without restrictions).

      Now, I will specify style-sheet for main-window: 

      QToolTip { max-width: 200px; }
      

       

      Actual result: As your can see, the height stays the same, the width decreased, so the text does not fit.

      Expected result: The height of the tooltip is not limited - so it should be increased!

       

      Suggested fix:

      https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qlabel.cpp.html#643

      return (contentsSize + contentsMargin).expandedTo(q->minimumSize());
      

      I think, here should be 

      return (contentsSize + contentsMargin).expandedTo(q->minimumSize()).boundedTo(q->maximumSize());
      

      But this suggestion might be mistaken because it is `QLabel` code, and it probably works fine probably fix should be in `QToolTip` code.

       

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            dry Vladislav
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes