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. Can QEvent setType?
Forum Updated to NodeBB v4.3 + New Features

Can QEvent setType?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.8k 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.
  • R Offline
    R Offline
    rigid
    wrote on last edited by
    #1

    I want to send a Deactivate event to application,
    but found that the new event
    QEvent event(QEvent::ApplicationDeactivate)
    can't be sent. (sendEvent() return false).

    then I need to change event type of the application current event.
    but I found QEvent dont have a setType() Function.

    How can I do that?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      sendEvent() returns the value that was returned from the event handler. QCoreApplication has no (default) implementation for ApplicationActivate and ApplicationDeactivate, thus false is returned. So your event is sent, but not handeled.

      In addition, I don't think you can deactivate an application by sending the ApplicationDeactivate event. The event just raises when you've been deactivated. I'm note even sure if an application can deactivate itself.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rigid
        wrote on last edited by
        #3

        actually I want to capture user action of click on dock icon.

        I found the even function in Application class will receive a message.

        @
        bool QQApplication::event(QEvent * event)
        {
        if(event->type() == QEvent::ApplicationActivate){
        ...
        }
        }
        @

        but the windows of my app are hidden instead of close.

        so when all windows close user click on the dock icon the app dosen't emit a activate even.

        So I want to sendevent() send a ApplicationDeactivate event when all windows are close.

        How can I do that?

        [quote author="Lukas Geyer" date="1322132584"]sendEvent() returns the value that was returned from the event handler. QCoreApplication has no (default) implementation for ApplicationActivate and ApplicationDeactivate, thus false is returned. So your event is sent, but not handeled.

        In addition, I don't think you can deactivate an application by sending the ApplicationDeactivate event. The event just raises when you've been deactivated. I'm note even sure if an application can deactivate itself.[/quote]

        [EDIT: code formatting, Volker]

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lgeyer
          wrote on last edited by
          #4

          So you basically just want the default behaviour on Mac OS where clicking the close button hides the application instead of closing it and a click to the dock icon should restore it, right?

          Well, I'm not a Qt on Mac OS expert but i think you'll have to revert to some platform-specific code (or at least macEvent() resp. macEventFilter()) to act accordingly.

          As a sidenote: more and more applications on Mac OS seem to act like Qt applications do by default - by closing the application when the close button is clicked.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            The application deactivate signal is sent, when the application is deactivated - quel surprise! Deactivation works by activating another application (you can see it by the menu bar changing the applications's name). To my knowledge and own user experience this is only possible by terminating the application or by using explicit means like the dock, the app chooser at cmd-tab, spaces or expose.

            If you close the last window of an app like iCal, iTunes or the Finder that application is still the current app (check the menu bar!).

            I never heard of an application that can "give away" its active state to another application. Even if it was possible, I as a user would be heavily annoyed by such behavior and I would most probably purge such an app from my disk.

            http://www.catb.org/~esr/faqs/smart-questions.html

            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