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. Styling a QDockWidget's title
QtWS25 Last Chance

Styling a QDockWidget's title

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 2.2k 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.
  • l3u_L Offline
    l3u_L Offline
    l3u_
    wrote on last edited by
    #1

    Hi :-)

    I used to set a style sheet for my program's QDockWidgets to style the title (make it bigger) like this:

    dock->setStyleSheet(QStringLiteral("QDockWidget { font-size: 18pt; }"));
    

    which worked fine until I updated to Qt 5.11 recently. The above code has no effect anymore. I also tried the QDockWidget::title subcontrol, but all font size settings there are also ignored.

    Is this a bug or a feature?! ;-) Or: How can I style a QDockwidget's title for both Qt 5.11 and older versions?

    Thanks for all help!

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

      Hi,

      Sounds like it could be a regression.

      On what platform do you observe that ? Did you check on another ?

      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
      0
      • l3u_L Offline
        l3u_L Offline
        l3u_
        wrote on last edited by
        #3

        I'm on Gentoo, using Qt 5.11.1. If you think it's a bug, I could also try to update to Qt 5.11.2 (also in portage) and see what happens …

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          No need to upgrade. It's a regression between 5.10.1 and 5.11. Can you please create a bug report?

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          l3u_L 1 Reply Last reply
          0
          • l3u_L Offline
            l3u_L Offline
            l3u_
            wrote on last edited by
            #5

            Thanks for the feedback, I'll file one :-)

            1 Reply Last reply
            0
            • l3u_L Offline
              l3u_L Offline
              l3u_
              wrote on last edited by
              #6

              Here we are: I just filed Bug #71382.

              1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                No need to upgrade. It's a regression between 5.10.1 and 5.11. Can you please create a bug report?

                l3u_L Offline
                l3u_L Offline
                l3u_
                wrote on last edited by
                #7

                @Christian-Ehrlicher Would it be possible to simply revert https://code.qt.io/cgit/qt/qtbase.git/commit/?id=3de8e74d773185b4c72b9fc730fdbb7275bed2d6 in my local Qt build to fix this for the moment? Or would this cause other trouble? I think it will take some time until a release having this fixed hits Gentoo's Portage tree …

                1 Reply Last reply
                0
                • l3u_L Offline
                  l3u_L Offline
                  l3u_
                  wrote on last edited by
                  #8

                  I just found Bug #70276, which seems to describe this very issue and points to a Patch apparently to be introduced with Qt 5.12: https://codereview.qt-project.org/#/c/241099/2/src/widgets/widgets/qdockwidget.cpp

                  So it's already fixed?!

                  1 Reply Last reply
                  0
                  • Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @l3u_ said in Styling a QDockWidget's title:

                    So it's already fixed?!

                    I would guess yes but need to take a look on it later on.

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    1 Reply Last reply
                    0
                    • l3u_L Offline
                      l3u_L Offline
                      l3u_
                      wrote on last edited by l3u_
                      #10

                      At least, the changes linked to the bug I found also fixes it for Qt 5.11.1. here's the patch I applied:

                      --- a/src/widgets/widgets/qdockwidget.cpp 2018-10-26 13:19:34.274455524 +0200
                      +++ b/src/widgets/widgets/qdockwidget.cpp 2018-10-26 13:22:18.305395057 +0200
                      @@ -691,7 +691,6 @@
                           // If we are in a floating tab, init from the parent because the attributes and the geometry
                           // of the title bar should be taken from the floating window.
                           option->initFrom(floatingTab && !isFloating() ? parentWidget() : this);
                      -    option->fontMetrics = QFontMetrics(d->font);
                           option->rect = dwlayout->titleArea();
                           option->title = d->fixedWindowTitle;
                           option->closable = hasFeature(this, QDockWidget::DockWidgetClosable);
                      @@ -1468,6 +1467,7 @@
                       void QDockWidget::paintEvent(QPaintEvent *event)
                       {
                           Q_UNUSED(event)
                      +    Q_D(QDockWidget);
                       
                           QDockWidgetLayout *layout
                               = qobject_cast<QDockWidgetLayout*>(this->layout());
                      @@ -1488,7 +1488,11 @@
                               // the title may wish to extend out to all sides (eg. Vista style)
                               QStyleOptionDockWidget titleOpt;
                               initStyleOption(&titleOpt);
                      -        p.setFont(d_func()->font);
                      +        if (font() == QApplication::font("QDockWidget")) {
                      +            titleOpt.fontMetrics = QFontMetrics(d->font);
                      +            p.setFont(d_func()->font);
                      +        }
                      +
                               p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt);
                           }
                       }
                      
                      1 Reply Last reply
                      0

                      • Login

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