Important: Please read the Qt Code of Conduct -

QDockWidget icons are blurry and SP_TitleBar pixmaps are different sizes?

  • I want to use Dock Widgets, but on my hi-dpi screen the title bar icons are blurry. I assume its not blurry for other people?

    I made a test with this code in a mainWindow constructor and the icons were all different sizes. See here:

    MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
        QWidget *wid = new QWidget(this);
        QVBoxLayout *layout = new QVBoxLayout;
        QStyle *style = this->style();
        QIcon closeIcon = style->standardIcon(QStyle::SP_TitleBarCloseButton);
        QIcon maxIcon = style->standardIcon(QStyle::SP_TitleBarMaxButton);
        QIcon minIcon = style->standardIcon(QStyle::SP_TitleBarMinButton);
        QIcon normalIcon = style->standardIcon(QStyle::SP_TitleBarNormalButton);
        qDebug() << closeIcon.availableSizes();
        qDebug() << maxIcon.availableSizes();
        qDebug() << minIcon.availableSizes();
        qDebug() << normalIcon.availableSizes();
        QPushButton *min = new QPushButton(this);
        QPushButton *max = new QPushButton(this);
        QPushButton *close = new QPushButton(this);
        QPushButton *normal = new QPushButton(this);
       wid->style()->standardIcon(QStyle::SP_DockWidgetCloseButton, nullptr, wid);

    Available sizes:
    (QSize(10, 10), QSize(16, 16), QSize(20, 20), QSize(32, 32), QSize(48, 48), QSize(64, 64))
    (QSize(10, 10))
    (QSize(10, 10))
    (QSize(10, 10), QSize(16, 16), QSize(20, 20), QSize(32, 32), QSize(48, 48), QSize(64, 64))

  • Lifetime Qt Champion

    What style do you use? The pixmaps are handled by the styles.

  • The Default, Windows, im on Windows 10.

    If I switch it to Fusion the icons are not blurry, but are low-res pixelated.

  • Lifetime Qt Champion

    Mhh . what qt version do you use? From a short look at the code I would have expected that SP_TitleBarMinButton returns the same values as SP_TitleBarNormalButton/SP_TitleBarCloseButton ...

  • The latest version, 5.11.1. I would expect them to be the same too. I wonder If someone else runs that code there will it have the same sizes for icons.

  • Now I found another bug where you cant set the background-color of a dock widget to white. Any other color works, but not white. wtf

    dock->setStyleSheet("background-color: black;"); = works
    dock->setStyleSheet("background-color: white;"); = fails
    dock->setStyleSheet("background-color: #ffffff;"); = fails

  • Alright, I found ways to fix all the issues that kept coming up, but its still a problem that the dock icons are not crisp.

    List of QDockWidget caveats / undocumented features:

    1. Floating dock windows has the Qt::Tool flag, which I find extremely ugly on windows 10, its got no border except for one line on top, the close icon icon has a gap off the top. I dont know where Windows itself uses this type of window, and I think QDockWidget should set floating window to Qt::Window, or give the option for it.
      Heres the code, would not need much to allow customisation.
    Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget;

    This is fixable with a workaround but I would prefer a method for it.

    1. Blurry icons, I override them with styles.
    QDockWidget {
        titlebar-close-icon: url(cross.png);
        titlebar-normal-icon: url(box.png);

    It looks good except the close icon looks very slightly different from normal window close icon because the rendering must be different.

    1. Styles inconsistent, this was more because stylesheets are weird. This works:
    QDockWidget::title {
        background: white;
    1. QMainWindow::addDockWidget() is not set, it may seem to still work, but it causes buggy behavior. Can:
    • Prevent dock widget from being moveable.
    • When you drag it the first time dock widget does not change window flag , and it moves way away from the mouse.

    Main issues:

    • Windows 'Tool' windows suck, add ability to set window flags.
    • addDockWidget is undocumented in QDockWidget doc page since its a QMainWindow method, but its essential.

  • Alright, one more. Its undocumented that if you dare use a widget without minimumSizeHint re-implemented as the setWidget of QDockWidget, it will cause an unslightly visual glitch when you try to dock it to a space where it shouldnt be able to fit.

    So a QWidget or QFrame will 100% everytime glitch visually.


    Example of size hints that fix the issue (must have at least minimumSizeHint)

    You may also see how the dock icons are not crisp, but the image resolution makes them look less bad than they are.

Log in to reply