Copied some example code but getting an error



  • I knew I am asking too many questions today but I promise this is the last one.

    I got the calculator code from "here":http://www.trinitydesktop.org/docs/qt4/script-calculator.html
    and made a project and put .js and .ui file in to that directory and copied main.cpp and qrc files

    But in main.cpp some includes could not be found so I changed from :

    then and there is no warning they are found or not

    @ #include <QApplication>
    #include <QUiLoader>
    #include <QtScript>
    #include <QWidget>
    #include <QFile>
    #include <QMainWindow>
    #include <QLineEdit>

    #ifndef QT_NO_SCRIPTTOOLS
    #include <QScriptEngineDebugger>
    #endif@

    to :

    @ #include <QApplication>
    #include <QtUiTools/QUiLoader>
    #include <QtScript/QtScript>
    #include <QWidget>
    #include <QFile>
    #include <QMainWindow>
    #include <QLineEdit>

    #ifndef QT_NO_SCRIPTTOOLS
    #include <QtScriptTools/QScriptEngineDebugger>
    #endif@

    But I when I try to run it , I get this error ; I don't what does it mean.

    @D:\qt\owo\main.cpp:45: error: C2065: 'qFindChild' : undeclared identifier

    D:\qt\owo\main.cpp:45: error: C2059: syntax error : '>'@

    also "here ":http://s10.postimg.org/nmb239w6h/Scrshot13.pngis the screen shot


  • Moderators

    hmmm.... i can't find the method qFindChild in the docs?! Only qFindChildren()
    You could change the line to this though:
    @
    QLineEdit* lineEdit = qFindChildren<QLineEdit*>(ui, "display").first(); // #include <QObject>
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.