How to remove Qt icon from QMdiSubWindow

Trying to remove Qt icon from QMdiSubWindow with little success. Below is an icon depicting the icon in the upper left corner.

enter image description here

Here is some code that looks like it should set Icon to empty, but not.

QMdiSubWindow* sub = new QMdiSubWindow;

sub->setAttribute( Qt::WA_DeleteOnClose );
sub->setWidget( myWidget );
sub->setWindowIcon( QIcon() );
//tried this too
//sub->setWindowIcon( QIcon("") );

mdiArea->addSubWindow( traceSub );

      

Thank!

+3


source to share


3 answers


This can be done simply:



sub->setWindowIcon( QIcon(QPixmap(1,1)) );

      

+5


source


I don't have a solution to remove it, but you can achieve the same result by setting a transparent icon. In my case, a 32x32 transparent png.

sub->setWindowIcon( QIcon("your_transparent_icon") );

      



enter image description here

enter image description here

+3


source


Removing / replacing Qt default window icon

First go to your user interface (user interface) form and enter the properties panel (it should be on the right side by default). Then scroll down the page until you see "windowIcon" and click in the window and select the down arrow. Changing window icon Qt

Then continue selecting the item as shown on the left side of my image box 1 . To add here, add items to resources from Qt. Here is some documentation on this - http://doc.qt.io/qt-5/resources.html

The other answers were acceptable, but did not go into details about accessing the UI, this is not a bad way to do it, but if you want to keep everything in code, you can easily do it.

// Replace relevant code, use ico files in UI (method shown above).
form->setWindowIcon(QIcon(QPixmap(1,1)));

      

Using .ico files is the best and more industry standard way as this scaling is related to the display due to the storage of different image sizes. Setting up a transparent icon is not the best thing, as when the user launches the application, they won't see it and it will look glitchy, but for testing it's okay.

+1


source







All Articles