Results 1 to 10 of 10

Thread: I Can't compile my slots,help!!!

  1. #1
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Question I Can't compile my slots,help!!!

    my class code:

    #ifndef GNETWORKCONNECTER_H
    #define GNETWORKCONNECTER_H

    #include <QString>
    #include <QTcpSocket>


    class GNetworkConnecter: public QTcpSocket
    {
    Q_OBJECT
    public:
    GNetworkConnecter(QObject *parent = 0);
    QString nextBlockSize;
    slots:
    void readFromClient();
    void linkBreak();
    };

    #endif

    ------------ make it

    In file included from src/GNetworkConnecter.cpp:1:
    src/GNetworkConnecter.h:19:7: warning: no newline at end of file
    src/GNetworkConnecter.h:15: error: expected primary-expression before ‘void’
    src/GNetworkConnecter.h:15: error: ISO C++ forbids declaration of ‘type name’ with no type
    src/GNetworkConnecter.h:15: error: expected ‘;’ before ‘void’

    ------------

    but if remove "slots:" then ok:

    class GNetworkConnecter: public QTcpSocket
    {
    Q_OBJECT
    public:
    GNetworkConnecter(QObject *parent = 0);
    QString nextBlockSize;
    void readFromClient();
    void linkBreak();
    };

    ----------
    why?

  2. #2
    Join Date
    Mar 2006
    Posts
    48
    Thanks
    5
    Thanked 4 Times in 3 Posts

    Default Re: I Can't compile my slots,help!!!

    change "slots:" to "private slots:" or "public slots:"

  3. #3
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: I Can't compile my slots,help!!!

    I change "slots:" to "private slots:" or "public slots:" then :


    g++ -c -pipe -g -D_REENTRANT -Wall -W -DQT_PLUGIN -DQT_SVG_LIB -DQT_QT3SUPPORT_LIB -DQT3_SUPPORT -DQT_SQL_LIB -DQT_XML_LIB -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.2.2/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.2.2/include/QtCore -I/usr/local/Trolltech/Qt-4.2.2/include/QtCore -I/usr/local/Trolltech/Qt-4.2.2/include/QtNetwork -I/usr/local/Trolltech/Qt-4.2.2/include/QtNetwork -I/usr/local/Trolltech/Qt-4.2.2/include/QtGui -I/usr/local/Trolltech/Qt-4.2.2/include/QtGui -I/usr/local/Trolltech/Qt-4.2.2/include/QtOpenGL -I/usr/local/Trolltech/Qt-4.2.2/include/QtOpenGL -I/usr/local/Trolltech/Qt-4.2.2/include/QtXml -I/usr/local/Trolltech/Qt-4.2.2/include/QtXml -I/usr/local/Trolltech/Qt-4.2.2/include/QtSql -I/usr/local/Trolltech/Qt-4.2.2/include/QtSql -I/usr/local/Trolltech/Qt-4.2.2/include/Qt3Support -I/usr/local/Trolltech/Qt-4.2.2/include/Qt3Support -I/usr/local/Trolltech/Qt-4.2.2/include/QtSvg -I/usr/local/Trolltech/Qt-4.2.2/include/QtSvg -I/usr/local/Trolltech/Qt-4.2.2/include -I. -I/usr/X11R6/include -Ibuild/.moc -Ibuild/.ui -o build/.o/unix/GNetworkConnecter.o src/GNetworkConnecter.cpp
    In file included from src/GNetworkConnecter.cpp:1:
    src/GNetworkConnecter.h:19:7: warning: no newline at end of file
    /usr/local/Trolltech/Qt-4.2.2/bin/moc -DQT_PLUGIN -DQT_SVG_LIB -DQT_QT3SUPPORT_LIB -DQT3_SUPPORT -DQT_SQL_LIB -DQT_XML_LIB -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.2.2/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.2.2/include/QtCore -I/usr/local/Trolltech/Qt-4.2.2/include/QtCore -I/usr/local/Trolltech/Qt-4.2.2/include/QtNetwork -I/usr/local/Trolltech/Qt-4.2.2/include/QtNetwork -I/usr/local/Trolltech/Qt-4.2.2/include/QtGui -I/usr/local/Trolltech/Qt-4.2.2/include/QtGui -I/usr/local/Trolltech/Qt-4.2.2/include/QtOpenGL -I/usr/local/Trolltech/Qt-4.2.2/include/QtOpenGL -I/usr/local/Trolltech/Qt-4.2.2/include/QtXml -I/usr/local/Trolltech/Qt-4.2.2/include/QtXml -I/usr/local/Trolltech/Qt-4.2.2/include/QtSql -I/usr/local/Trolltech/Qt-4.2.2/include/QtSql -I/usr/local/Trolltech/Qt-4.2.2/include/Qt3Support -I/usr/local/Trolltech/Qt-4.2.2/include/Qt3Support -I/usr/local/Trolltech/Qt-4.2.2/include/QtSvg -I/usr/local/Trolltech/Qt-4.2.2/include/QtSvg -I/usr/local/Trolltech/Qt-4.2.2/include -I. -I/usr/X11R6/include -Ibuild/.moc -Ibuild/.ui src/GNetworkConnecter.h -o build/.moc/moc_GNetworkConnecter.cpp
    g++ -c -pipe -g -D_REENTRANT -Wall -W -DQT_PLUGIN -DQT_SVG_LIB -DQT_QT3SUPPORT_LIB -DQT3_SUPPORT -DQT_SQL_LIB -DQT_XML_LIB -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.2.2/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.2.2/include/QtCore -I/usr/local/Trolltech/Qt-4.2.2/include/QtCore -I/usr/local/Trolltech/Qt-4.2.2/include/QtNetwork -I/usr/local/Trolltech/Qt-4.2.2/include/QtNetwork -I/usr/local/Trolltech/Qt-4.2.2/include/QtGui -I/usr/local/Trolltech/Qt-4.2.2/include/QtGui -I/usr/local/Trolltech/Qt-4.2.2/include/QtOpenGL -I/usr/local/Trolltech/Qt-4.2.2/include/QtOpenGL -I/usr/local/Trolltech/Qt-4.2.2/include/QtXml -I/usr/local/Trolltech/Qt-4.2.2/include/QtXml -I/usr/local/Trolltech/Qt-4.2.2/include/QtSql -I/usr/local/Trolltech/Qt-4.2.2/include/QtSql -I/usr/local/Trolltech/Qt-4.2.2/include/Qt3Support -I/usr/local/Trolltech/Qt-4.2.2/include/Qt3Support -I/usr/local/Trolltech/Qt-4.2.2/include/QtSvg -I/usr/local/Trolltech/Qt-4.2.2/include/QtSvg -I/usr/local/Trolltech/Qt-4.2.2/include -I. -I/usr/X11R6/include -Ibuild/.moc -Ibuild/.ui -o build/.o/unix/moc_GNetworkConnecter.o build/.moc/moc_GNetworkConnecter.cpp
    In file included from build/.moc/moc_GNetworkConnecter.cpp:10:
    build/.moc/../../src/GNetworkConnecter.h:19:7: warning: no newline at end of file
    g++ -Wl,-rpath,/usr/local/Trolltech/Qt-4.2.2/lib -o QTGameServerLinux build/.o/unix/main.o build/.o/unix/GDataBaseConnecter.o build/.o/unix/GNetworkConnecter.o build/.o/unix/moc_GNetworkConnecter.o -L/usr/local/Trolltech/Qt-4.2.2/lib -L/usr/X11R6/lib -lQtSvg -L/home/fengtian/qt-x11-opensource-src-4.2.2/lib -L/usr/X11R6/lib -lQt3Support -lQtSql -lQtXml -lQtOpenGL -lQtGui -lpng -lSM -lICE -lXi -lXrender -lXrandr -lXfixes -lXcursor -lXinerama -lfreetype -lfontconfig -lXext -lX11 -lQtNetwork -lQtCore -lz -lm -lglib-2.0 -ldl -lGLU -lGL -lpthread
    build/.o/unix/moc_GNetworkConnecter.o: In function `GNetworkConnecter::qt_metacall(QMetaObject::Call, int, void**)':
    build/.moc/moc_GNetworkConnecter.cpp:66GNetworkConnecter::rea dFromClient()
    build/.moc/moc_GNetworkConnecter.cpp:67GNetworkConnecter::lin kBreak()
    collect2: ld returned 1 exit status

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: I Can't compile my slots,help!!!

    Does it help if you re-run qmake? Maybe the meta object compiler failed to do its job perfectly because of the misspelling..
    J-P Nurmi

  5. #5
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: I Can't compile my slots,help!!!

    and I used "MonkeyStudio" IDE to creat QT App

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: I Can't compile my slots,help!!!

    But you do know how to compile the app from the command line, right?

    Once you have verified it compiles from the command line you can be sure that the problem is not with the sources or the project file. I have never used Monkey Studio so I don't know how does it work or whether you can somehow invoke qmake.
    J-P Nurmi

  7. #7
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: I Can't compile my slots,help!!!

    I got it! Ha ha ~

    slots must is "private" or "public",and must defined

    is OK!! thanks everyone~

  8. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: I Can't compile my slots,help!!!

    Quote Originally Posted by fengtian.we View Post
    slots must is "private" or "public",and must defined
    Did you not notice the reply by evgenM?
    J-P Nurmi

  9. #9
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: I Can't compile my slots,help!!!

    I see it , and change "slots:" to "private slots:" .

    but no defined the slot , so........

    hehe

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: I Can't compile my slots,help!!!

    The slot is a regular method, so obviously it has to be defined... You only don't implement signals as moc does this for you.

Similar Threads

  1. Qt-4.2.2 qmake won't compile under visual studio 2005 on vista
    By moowy in forum Installation and Deployment
    Replies: 7
    Last Post: 13th January 2007, 21:06
  2. Need to compile with MySQL drivers/plugins
    By mongenix in forum Newbie
    Replies: 5
    Last Post: 6th January 2007, 20:24
  3. Compile Errors
    By luffy27 in forum Qt Programming
    Replies: 3
    Last Post: 4th November 2006, 05:26
  4. Project won't compile under Windows (works under Linux)
    By philski in forum Qt Programming
    Replies: 7
    Last Post: 14th September 2006, 15:29
  5. how to correctly compile threads support?
    By srhlefty in forum Installation and Deployment
    Replies: 9
    Last Post: 25th June 2006, 19:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.