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?
Re: I Can't compile my slots,help!!!
change "slots:" to "private slots:" or "public slots:"
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
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..
Re: I Can't compile my slots,help!!!
and I used "MonkeyStudio" IDE to creat QT App
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.
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~
Re: I Can't compile my slots,help!!!
Quote:
Originally Posted by
fengtian.we
slots must is "private" or "public",and must defined:)
Did you not notice the reply by evgenM? :)
Re: I Can't compile my slots,help!!!
:p I see it , and change "slots:" to "private slots:" .
but no defined the slot , so........
hehe :eek:
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.