forked from qt-creator/qt-creator
Fix that tool tips for long texts became too small
If the unwrapped tool tip is too long, we may not use the "preferred" width of the label with word wrap on, because turning on word wrap makes the preferred width very small. That would lead to tool tips with long text becoming very small instead of "as large as possible but with word wrap". Instead set the width to the largest that we deem desired, and let the label word wrap on that. As an example look at the tool tip on styleHint or setMask in tips.cpp Change-Id: Id804b6ea4e4a872e65dd7f49eb3cd52553c04cfe Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -166,11 +166,7 @@ void TextTip::configure(const QPoint &pos, QWidget *w)
|
||||
const int maxDesiredWidth = int(screenWidth * .5);
|
||||
if (tipWidth > maxDesiredWidth) {
|
||||
setWordWrap(true);
|
||||
tipWidth = sizeHint().width();
|
||||
// If the width is still too large (maybe due to some extremely long word which prevents
|
||||
// wrapping), the tip is truncated according to the screen.
|
||||
if (tipWidth > screenWidth)
|
||||
tipWidth = screenWidth - 10;
|
||||
tipWidth = maxDesiredWidth;
|
||||
}
|
||||
|
||||
resize(tipWidth, heightForWidth(tipWidth) + extraHeight);
|
||||
|
||||
Reference in New Issue
Block a user