[Solved] Cannot get any focus signal
-
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? -
@Zylann I think the signal should be
void QApplication::focusChanged(QWidget * old, QWidget * now)
, notfocusWidgetChanged
.Could you please try with that
signal
? -
I tried too, it didn't works either.
-
@Zylann Which platform are you using? Linux, Windows, OS?
-
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? -
@Zylann In the next example:
<your_qt_dir>\Examples\Qt-5.5\help\contextsensitivehelp
You can see how the
signal
is working. -
@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 *)) );
-
Ooooh yes, it fixed the problem :'D
Thank you ! -
@Zylann Great! :)
Please, mark the post as solved ;)