Reputation: 2708
Trying to remove the Qt Icon from a QMdiSubWindow with little success. Below is a picture showing the icon in the top left corner.
Here is some code, which seems like it should set the Icon to empty, but does 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 );
Thanks!
Upvotes: 3
Views: 2721
Reputation: 1520
Guess I'm a little late to the party, but I just figured out that QPixmap allows to be filled with Qt::transparent. Therefor there's no need for an external transparent 32x32 image.
QPixmap pixmap{32, 32};
pixmap.fill(Qt::transparent);
setWindowIcon(QIcon{pixmap});
Upvotes: 1
Reputation: 110
Deleting/replacing Qt default window icon
Firstly navigate to your UI (User Interface) form and access the properties bar (should be on the right hand side default).
Then scroll down till you see "windowIcon" and click into the box and select the drop down arrow.
Then continue to select an item, as shown in the left hand side box of my image1. To add here add items in resources from Qt. Here's some documentation on this - http://doc.qt.io/qt-5/resources.html
The other answers were acceptable but did not go into detail about accessing from the UI, this is not a bad way to do it but if you want to keep everything in the code you can easily do so.
// Replace relevant code, use ico files in UI (method shown above).
form->setWindowIcon(QIcon(QPixmap(1,1)));
Using .ico files is a better and more industry standard way as this scales relevant to the display due to holding various sizes of the image. Setting a transparent icon isn't the best thing to do, as when the user runs the app they will not see it and it will look buggy - but for testing this is fine.
Upvotes: 1
Reputation: 32665
This could be done simply by :
sub->setWindowIcon( QIcon(QPixmap(1,1)) );
Upvotes: 7
Reputation: 41775
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") );
Upvotes: 4