[Solved] Use of signal-slot connect in Windows 10
-
Do you have the same problem if you use the new syntax ?
-
Do you get any output when you add
qDebug("Hello!")
orqWarning("Hello!")
to your code? If not, that means your debug output has been disabled (that's why you don't see the message). Make sure your project doesn't defineQT_NO_DEBUG_OUTPUT
,QT_NO_WARNING_OUTPUT
, etc.I'm on Windows 10 Pro (64-bit), using Qt 5.4.2 for MSVC 2013 32-bit. When I try to connect a signal to a non-existent slot, I get this message in my Qt Creator "Application Output" pane:
QObject::connect: No such slot MyObject::fakeSlot() in ..\TestProg\main.cpp:32
@SGaist said:
Do you have the same problem if you use the new syntax ?
The problem won't exist with the new syntax, because the compiler will detect the error and stop the build ;)
-
@SGaist @mrjj @JKSH
Sorry guys. I had apparently another notification issue here in the forum. Not sure, if I simply missed the notification.Thanks for pointing towards the new syntax. Have not been aware of this, because I do not read each time I am using Qt constructs in the docs. However, when the syntax causes the compiler to complain, that is really cool and saves the time.
Actually I consider it also as strange that the OS shall have such an effect.
-
@koahnig: No problem :)
By the way, since you're new to the new syntax, I hope this article will be helpful to you: http://doc.qt.io/qt-5/signalsandslots-syntaxes.html
-
-
May I humbly suggest to follow your signature ? ;)
-
@koahnig said:
The warning at wrong connects still seems to be gone.
I get the error message for wrong connections, and I'm using Qt 5.5.1 MinGW 4.9.2 32-bit and Qt 5.4.2 MSVC 2013 32-bit on Windows 10 Pro 64-bit.
Does qDebug() and qWarning() work for you?
-
@JKSH said:
I get the error message for wrong connections, and I'm using Qt 5.5.1 MinGW 4.9.2 32-bit and Qt 5.4.2 MSVC 2013 32-bit on Windows 10 Pro 64-bit.
Does qDebug() and qWarning() work for you?
I am using qDebug all the time. It does work.
-
@JKSH
qWarning is also working.
However, your last question brought up a clue of what might have been the case.I am using a message handler for redirecting the output of qDebug. It allows to ignore all output, to store all to a file and/or to the screen.
Since there is a lot of output, the screen output is slowing down dramatically. Therefore, I have redirected the output only to the file. The assert was probably kicking in before the message was written to the file. I have seen this with other output before, but never with the warning for connection failures (Probably I had also screen output then).Anyway even when the problem was between chair and keyboard, it was good to have the discussion. Otherwise I would not have learnt about the new syntax.
Thanks again.
-
A point I have missed in my previous response.
I have written a small test this time.
#include "Clas.h" #include <QTimer> #include <QDebug> Clas::Clas(QObject *parent) : QObject(parent) { QTimer *timea = new QTimer ( this ); connect ( timea, SIGNAL ( timerout() ), this, SLOT (sltQuit() ) ); qDebug() << "debug"; qWarning() << "warning"; } void Clas::sltQuit() { }
and here is the output
Qt: Untested Windows version 10.0 detected! QObject::connect: No such signal QTimer::timerout() in ..\..\Test\CheckConnect\Clas.cpp:9 debug warning
So it is working perfectly also on windows 10 with MinGW version Qt 5.4.1.
-
Just saw something: the warning's right, the signal is timeout not timerout
-
Great! :)