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. Get windows handle?

Get windows handle?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 5.2k Views 1 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.
  • S Offline
    S Offline
    SavageTwinky
    wrote on last edited by
    #1

    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)
    {

    ui.setupUi(this)

    RegisterDeviceNotification(this->winId(),&NotificationFilter,DEVICE_NOTIFY_WINDOW_HANDLE);
    }

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

    This won't compile so i used this line instead

    @RegisterDeviceNotification(ui.centralWidget->winId(),&NotificationFilter,DEVICE_NOTIFY_WINDOW_HANDLE);@

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

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      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.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SavageTwinky
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          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":http://doc.qt.nokia.com/4.7/qwidget.html#winId exists. I already used it, it exists and works. Which errors do you get if you use it?

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          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