Get windows handle?

  • I know about QWidget::winId() but the problem is it doesn't seem to work in a class that is derived from QMAinWindow

    MainApp::MainApp(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)



    bool MainApp::winEvent ( MSG * msg, long * result )
    // do stuff on filtered devices

    This won't compile so i used this line instead


    But it doesn't work, I don't get the filtered messages in winEvent();

  • Hi,

    First of all, why does the first sollution not compile?
    The second one has no valid winodw handle, as sub widgets are not native windows! Only top level widgets have a window handle.

  • well the class derived from QMainWindow doesn't seem to have QMainWindow::winId()

    Shouldn't it get inherited by QWidget?

    Is there an alternative in Qt to getting usb events and keeping track of active connections? that would probably be easier, though we don't want to use polling.

  • No, Qt has not direct driver support, so no direct possibility in Qt to get USB events.

    QMainWindow is derived from QWidget, so the method "winId": exists. I already used it, it exists and works. Which errors do you get if you use it?

Log in to reply