Important: Please read the Qt Code of Conduct -

New signall slot syntax

  • Hi I just try to use new yntax and for testing that i wrote this simple code :
    #include "mainwindow.h"
    #include <QApplication>

    int main(int argc, char argv[])
    QApplication a(argc, argv);
    lbl=new QLabel;
    QTimer *timer=new QTimer;
    int x=0;
    return a.exec();
    but when i build the code i get the following error
    /home/mohsen/qt_projects/qt_android/main.cpp:15: error: expected expression

    any suggestions?

  • The syntax looks correct, one thing that can cause the error is that you didn't enabled the C++11 for your C++ compiler (the android ndk seems to use gcc 4.8), so you need to add this line into your .pro file: @QMAKE_CXXFLAGS += -std=c++11@

    And if you build the same project with a visual c++ that doesn't need (or know) that flag, you can use this:
    @gcc : QMAKE_CXXFLAGS += -std=c++11@
    to add the flag only for gcc.

  • thanks it solved

Log in to reply