Skip to content

Instantly share code, notes, and snippets.

@vprus
Created July 24, 2015 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vprus/a64cd0ea5a6e17149ad4 to your computer and use it in GitHub Desktop.
Save vprus/a64cd0ea5a6e17149ad4 to your computer and use it in GitHub Desktop.
#include <QCoreApplication>
#include <QTimer>
struct Test : public QObject
{
void foo() {}
};
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QTimer::singleShot(1000, &Test::foo);
return a.exec();
}
@suy
Copy link

suy commented Jul 24, 2015

This is the error with 4.7.2:

In file included from /mnt/backups/local/qt/5.4/gcc_64/include/QtCore/QTimer:1:0,
                 from main.cpp:2:
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h: In instantiation of ‘static void QTimer::singleShot(int, Func1) [with Func1 = void (Test::*)()]’:
main.cpp:13:40:   required from here
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:107:9: error: no matching function for call to ‘QTimer::singleShot(int&, Qt::TimerType, NULL, void (Test::*&)())’
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:107:9: note: candidates are:
In file included from /mnt/backups/local/qt/5.4/gcc_64/include/QtCore/QTimer:1:0,
                 from main.cpp:2:
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:73:17: note: static void QTimer::singleShot(int, const QObject*, const char*)
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:73:17: note:   candidate expects 3 arguments, 4 provided
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:74:17: note: static void QTimer::singleShot(int, Qt::TimerType, const QObject*, const char*)
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:74:17: note:   no known conversion for argument 4 from ‘void (Test::*)()’ to ‘const char*’
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:86:24: note: template<class Func1> static void QTimer::singleShot(int, const typename QtPrivate::FunctionPointer<Func1>::Object*, Func1)
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:86:24: note:   template argument deduction/substitution failed:
In file included from /mnt/backups/local/qt/5.4/gcc_64/include/QtCore/QTimer:1:0,
                 from main.cpp:2:
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:107:9: note:   mismatched types ‘const typename QtPrivate::FunctionPointer<Func1>::Object*’ and ‘Qt::TimerType’
In file included from /mnt/backups/local/qt/5.4/gcc_64/include/QtCore/QTimer:1:0,
                 from main.cpp:2:
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:91:24: note: template<class Func1> static void QTimer::singleShot(int, Qt::TimerType, const typename QtPrivate::FunctionPointer<Func1>::Object*, Func1)
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:91:24: note:   template argument deduction/substitution failed:
In file included from /mnt/backups/local/qt/5.4/gcc_64/include/QtCore/QTimer:1:0,
                 from main.cpp:2:
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:107:9: note:   mismatched types ‘const typename QtPrivate::FunctionPointer<Func1>::Object*’ and ‘long int’
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:105:24: note: template<class Func1> static void QTimer::singleShot(int, Func1)
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:105:24: note:   template argument deduction/substitution failed:
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:107:9: note:   candidate expects 2 arguments, 4 provided
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:110:24: note: template<class Func1> static void QTimer::singleShot(int, Qt::TimerType, Func1)
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:110:24: note:   template argument deduction/substitution failed:
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:107:9: note:   candidate expects 3 arguments, 4 provided
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:118:13: note: template<class Func1> static typename QtPrivate::QEnableIf<((! QtPrivate::FunctionPointer<Func>::IsPointerToMemberFunction) && (! QtPrivate::is_same<const char*, Func1>::value)), void>::Type QTimer::singleShot(int, QObject*, Func1)
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:118:13: note:   template argument deduction/substitution failed:
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:107:9: note:   cannot convert ‘((msec > 1999) ? (Qt::TimerType)1u : (Qt::TimerType)0u)’ (type ‘Qt::TimerType’) to type ‘QObject*’
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:125:13: note: template<class Func1> static typename QtPrivate::QEnableIf<((! QtPrivate::FunctionPointer<Func>::IsPointerToMemberFunction) && (! QtPrivate::is_same<const char*, Func1>::value)), void>::Type QTimer::singleShot(int, Qt::TimerType, QObject*, Func1)
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:125:13: note:   template argument deduction/substitution failed:
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h: In substitution of ‘template<class Func1> static typename QtPrivate::QEnableIf<((! QtPrivate::FunctionPointer<Func>::IsPointerToMemberFunction) && (! QtPrivate::is_same<const char*, Func1>::value)), void>::Type QTimer::singleShot(int, Qt::TimerType, QObject*, Func1) [with Func1 = void (Test::*)()]’:
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:107:9:   required from ‘static void QTimer::singleShot(int, Func1) [with Func1 = void (Test::*)()]’
main.cpp:13:40:   required from here
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qtimer.h:125:13: error: invalid use of incomplete type ‘struct QtPrivate::QEnableIf<false, void>’
In file included from /mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qcoreapplication.h:37:0,
                 from /mnt/backups/local/qt/5.4/gcc_64/include/QtCore/QCoreApplication:1,
                 from main.cpp:1:
/mnt/backups/local/qt/5.4/gcc_64/include/QtCore/qglobal.h:1058:45: error: declaration of ‘struct QtPrivate::QEnableIf<false, void>’
make: *** [main.o] Error 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment