Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
windowHandle() will return NULL;
chaochao last edited by kshegunov
In manual ,QWidget::windowHandle() returns a valid instance of a QWindow only after the widget has been shown. It is therefore recommended to delay the initialization of the QWinTaskbarButton instances until QWidget::showEvent().
But how to know the time widget has been shown? I didn't override showEvent.
_taskbarbutton = new QWinTaskbarButton( this); _taskbarbutton->setWindow(windowHandle());
this code will be wrong,because windowHandle() return NULL;
QtWin::enableBlurBehindWindow(this); _taskbarbutton = new QWinTaskbarButton( this); _taskbarbutton->setWindow(windowHandle());
This code will be ok!
So,How to know what time windowHandle()is valid?
thank for your help.
[Edit: Added code tags ~kshegunov]
Then, why not just re-implement the showEvent method ?