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. [Solved] Cannot get any focus signal
Forum Updated to NodeBB v4.3 + New Features

[Solved] Cannot get any focus signal

Scheduled Pinned Locked Moved General and Desktop
focusdesktop
9 Posts 2 Posters 5.1k 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.
  • Z Offline
    Z Offline
    Zylann
    wrote on last edited by Zylann
    #1

    Hello,
    we are trying to debug a focus problem in our application, and it seems QApplication::focusWidgetChanged is never emitted.
    I created a simple object just to listen the signals like this:

    			connect(
    				app, SIGNAL(focusWidgetChanged(QWidget * old, QWidget * now)), 
    				this, SLOT(onFocusWidgetChanged(QWidget * old, QWidget * now))
    			);
    			connect(
    				app, SIGNAL(focusWindowChanged(QWidget * now)), 
    				this, SLOT(onFocusWindowChanged(QWidget * now))
    			);
    

    We have forms, multiple docks and windows in our application, but none of these focus signals are called Oo
    How can I know when something is focused? Or does it really means there is no focusing at all in the application?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tarod.net
      wrote on last edited by
      #2

      @Zylann I think the signal should be void QApplication::focusChanged(QWidget * old, QWidget * now), not focusWidgetChanged.

      Could you please try with that signal?

      "Individually, we are one drop. Together, we are an ocean."

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        Zylann
        wrote on last edited by
        #3

        I tried too, it didn't works either.

        T 1 Reply Last reply
        0
        • Z Zylann

          I tried too, it didn't works either.

          T Offline
          T Offline
          tarod.net
          wrote on last edited by
          #4

          @Zylann Which platform are you using? Linux, Windows, OS?

          "Individually, we are one drop. Together, we are an ocean."

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            Zylann
            wrote on last edited by Zylann
            #5

            I use Windows 7 64 bits, with Visual Studio 2013 as IDE.

            EDIT: I just noticed these warnings:
            [Warning] QObject::connect: No such signal QApplication::focusChanged(QWidget * old, QWidget * now)
            [Warning] QObject::connect: No such signal QApplication::focusWindowChanged(QWidget * now)
            But these signals exist?

            T 2 Replies Last reply
            0
            • Z Zylann

              I use Windows 7 64 bits, with Visual Studio 2013 as IDE.

              EDIT: I just noticed these warnings:
              [Warning] QObject::connect: No such signal QApplication::focusChanged(QWidget * old, QWidget * now)
              [Warning] QObject::connect: No such signal QApplication::focusWindowChanged(QWidget * now)
              But these signals exist?

              T Offline
              T Offline
              tarod.net
              wrote on last edited by
              #6

              @Zylann In the next example:

              <your_qt_dir>\Examples\Qt-5.5\help\contextsensitivehelp
              

              You can see how the signal is working.

              "Individually, we are one drop. Together, we are an ocean."

              1 Reply Last reply
              0
              • Z Zylann

                I use Windows 7 64 bits, with Visual Studio 2013 as IDE.

                EDIT: I just noticed these warnings:
                [Warning] QObject::connect: No such signal QApplication::focusChanged(QWidget * old, QWidget * now)
                [Warning] QObject::connect: No such signal QApplication::focusWindowChanged(QWidget * now)
                But these signals exist?

                T Offline
                T Offline
                tarod.net
                wrote on last edited by tarod.net
                #7

                @Zylann OMG :) I see where the problem is.

                You don't need to name your input variables in the signal/slot methods.

                    connect(app, SIGNAL(focusChanged(QWidget *, QWidget *)), 
                            this, SLOT(focusChanged(QWidget *, QWidget *))
                            ); 
                

                "Individually, we are one drop. Together, we are an ocean."

                1 Reply Last reply
                0
                • Z Offline
                  Z Offline
                  Zylann
                  wrote on last edited by
                  #8

                  Ooooh yes, it fixed the problem :'D
                  Thank you !

                  T 1 Reply Last reply
                  1
                  • Z Zylann

                    Ooooh yes, it fixed the problem :'D
                    Thank you !

                    T Offline
                    T Offline
                    tarod.net
                    wrote on last edited by
                    #9

                    @Zylann Great! :)

                    Please, mark the post as solved ;)

                    "Individually, we are one drop. Together, we are an ocean."

                    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