Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. windowHandle() will return NULL;
Forum Updated to NodeBB v4.3 + New Features

windowHandle() will return NULL;

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 3.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • chaochaoC Offline
    chaochaoC Offline
    chaochao
    wrote on last edited by kshegunov
    #1

    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]

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Then, why not just re-implement the showEvent method ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved