Solved QMainWindow with own dialog taskbar icon
-
Hi,
I have a dialog in an Application. The dialog is derived from QMainWindow and lives in the bigger Application which creates and destroys the dialog. I know that QmainWindow is not the correct class to use for a sub-dialog but changing that is a task for another day.
The issue is, when the dialog is open, it doesnt have a taskbar icon. When minimized, it reduces itself to a tiny window at the lower left corner where it can be reopened by clicking the respective icon on it but our customer wants it to be accessible through a taskbar icon.
I've read that it should actually be having an own icon by default, but since our App still uses MFC, there is a wrapper that ensures compatibility. Basically an instance of the wrapper class (QWinWidget) is created and the dialog is then created with the wrapper class as parent. I assume this is the cause for this behaviour.
Any ideas on how to achieve that?
-
Hi @flautzr ,
If you let the parent of your dialog to
null_ptr
, it should create a "standalone" window with its own taskbar icon. -
Hi @flautzr ,
If you let the parent of your dialog to
null_ptr
, it should create a "standalone" window with its own taskbar icon. -
@Gojir4
Ooohhh, that's a good one (provided it works!) :)Hang on though! Remember, the OP is not using a
QDialog
for the "dialog" only aQMainWindow
. Does that "null parent produces taskbar icon" require a Windows dialog? -
@Gojir4 This does work surprisingly ...
i never doubted your suggestion, what surprises me is the wrapper class around the dialog is not needed at all so now I have to talk to my fellow developer what this means.
thanks for the solution!
-
@JonB said in QMainWindow with own dialog taskbar icon:
Does that "null parent produces taskbar icon" require a Windows dialog?
That's behavior of any QWidget so no matter if it's a QMainWindow or a QDialog.
I just did test with Python and I see the same result using a dialog .As said in the doc of QWidget:
If parent is nullptr, the new widget becomes a window. If parent is another widget, this widget becomes a child window inside parent. The new widget is deleted when its parent is deleted.