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. WinId and WinIdChange

WinId and WinIdChange

Scheduled Pinned Locked Moved General and Desktop
13 Posts 3 Posters 11.0k 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.
  • H Offline
    H Offline
    heorhiy
    wrote on last edited by
    #1

    This code cause infinity cycle. So when I'm pressing button winId is calling and cause QEvent::WinIdChange.
    Inside Event handler winid is called again to obtain new winId and it cause one more QEvent::WinIdChange event and so on. What I'm doing wrong. Thank you.

    @void ProcessTab::OnButtonClick()
    {
    set(winId());
    }

    bool ProcessTab::event( QEvent* event )
    {
    if (event->type() == QEvent::WinIdChange){
    set(winId());
    return true;
    }
    return QWidget::event(event);
    }@

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

      what does set() do?
      perhaps it's related to this call?

      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
      • H Offline
        H Offline
        heorhiy
        wrote on last edited by
        #3

        nothing for tests set is just
        void set(HWND h){
        }

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

          Hi heorhiy,

          have you read the docs?

          bq. If a widget is non-native (alien) and winId() is invoked on it, that widget will be provided a native handle.
          On Mac OS X, the type returned depends on which framework Qt was linked against. If Qt is using Carbon, the {WId} is actually an HIViewRef. If Qt is using Cocoa, {WId} is a pointer to an NSView.
          This value may change at run-time. An event with type QEvent::WinIdChange will be sent to the widget following a change in window system identifier.

          Might it be that you ahve a non native window (a child) where you call winId()?

          Then it might be created on runtime as temporary HWND.

          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
          • H Offline
            H Offline
            heorhiy
            wrote on last edited by
            #5

            Hi,
            Yes it seems that it is non native window.
            Ok it creates temprorary HWND but why it cause infinity cycle, is it bug ?
            Or maybe I shouldn't catch WinIdChange? But there is bothing about that in documentation.

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

              calling winId creates a temporary HWND and emits winIdChange. in winIdChange you call winId

              inside the winIdChanged event, you should perhaps call QWidget::internalWinId which just returns the id and does not do any creational stuff...

              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
              • H Offline
                H Offline
                heorhiy
                wrote on last edited by
                #7

                Thank you, it works fine.
                But I Didn't find any mention about QWidget::internalWinId in documentation.

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

                  I found it in the code :-))

                  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
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #9

                    But that is a bit weird behaviour, isn't it? I mean, the WinIdChanged event is just a QEvent, so it does not carry the changed id (right?). So, what are you supposed to do when you receive that event then? If you actually want to react to it and use the changed id, you have to call winId(), which in turn will trigger a change, if I understand you correctly.

                    I can understand that heorhiy is confused on this.

                    1 Reply Last reply
                    0
                    • H Offline
                      H Offline
                      heorhiy
                      wrote on last edited by
                      #10

                      Yes, but it means that it's internal function and could disappear or be changed in any moment (:

                      Any way, now everything work, thank you much.

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

                        I think it could be a bug, perhaps the event is send before some attributes are set so calling winId causes another loop. calling internalWinId just returns the value, never creates anything.

                        Shall we submit a bug report for 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
                        • A Offline
                          A Offline
                          andre
                          wrote on last edited by
                          #12

                          I think that either calling winId() should not trigger a change in the winId (though it might trigger the first creation of one), or the WinIdChanged event needs an event subclass of its own that includes the actual value of the new winId. As it stands, it seems quite useless.

                          Yes, I think a report is in order.

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

                            Created a bug report: "QTBUG-18132":http://bugreports.qt.nokia.com/browse/QTBUG-18132

                            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