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

QComboBox tooltip with style sheet doesn't fit text in frame

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.4.0
    • Widgets: Style Sheets
    • None
    • windows

      This bug have been in QTBUG-15009 earlier. Reproduced again in 5.4.0. I have tested bug in Python too:

      code:

      import sys
      
      if 'qt4' in sys.argv:
          sys.argv.remove('qt4')
          from PyQt4.QtCore import *
          from PyQt4.QtGui import *
      else:
          from PyQt5.QtCore import *
          from PyQt5.QtWidgets import *
      
      
      class WidgetGallery(QDialog):
          def __init__(self, parent=None):
              super(WidgetGallery, self).__init__(parent)
              
              b = QPushButton('html')
              b.setToolTip("<nobr>Words: <b>only one-God</b></nobr>");
              
              c = QComboBox()
              c.addItem('html')
              c.setToolTip("<nobr>Words: <b>only one-God</b></nobr>");
      
              cb = QComboBox()
              cb.addItem('text')
              cb.setToolTip("simple text");
              
              lay = QHBoxLayout()
              lay.addWidget(b)
              lay.addWidget(c)
              lay.addWidget(cb)
              self.setLayout(lay)
      
      
      if __name__ == '__main__':
          app = QApplication(sys.argv)
          app.setStyleSheet(r'''QToolTip
      {
      	font-size: 12pt;
      	color: #FFFF00;
      	border: 1px solid #FF0000;
      	background-color: #000000;
      }''')
          gallery = WidgetGallery()
          gallery.setWindowTitle('Qt '+qVersion())
          gallery.show()
          sys.exit(app.exec_())  
      

      Additional behavior:
      While first tooltip not closed and if popup new tooltip, then frame of new tooltip will be right.

      After all
      While debugging Qt sources i found something interesting:
      At calculating function QLabelPrivate::sizeForWidth fields leftmargin rightmargin of QFramePrivate is used. But that fields initialized later than QTipLabel init. Function QFramePrivate::updateStyledFrameWidths initialize fields of frame after QTipLabel have been rendered.
      When new tooltip requested QTipLabel use reuseTip with right QFramePrivate parameters.

      And finally tooltip driven by another widget like QPushButton haven't that bug.

        1. pNPmvoU.png
          35 kB
          Artem Pavlenko
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Unassigned Unassigned
            artnamed Artem Pavlenko
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes