Qt World Summit: Register Today!

QDockWidget Window Icon

  • Hi,

    I tried the following code to add a icon to QDockWidget

    m_pConsoleDockWidget = new QDockWidget(this);
    m_pConsoleDockWidget->setObjectName(QStringLiteral("Console Dock Widget"));


    I am not able to see the icon. kindly help me

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Is "Resources/UI/icons/Console.png" in your source folder ? If so, at run time the file won't be found. You would either give the full path or put the image in a Qt resource file and load it from there.

  • Hi, Thanks for the reply.
    The resource is in the following path“Resources/UI/icons/Console.png”. I have loaded the resource from Qt resource file. But i am not able to see the icon.

    I have followed the same method for loading the resource for QTabWidgets etc.,, It is working for QTabWidgets. But not for QDockWidgets


  • Lifetime Qt Champion

    Sorry, I misread your code. QDockWidget doesn't have an window icon

Log in to reply