Hi,
I tried porting one of my widgets from qt3 to qt4 (rewriting it from the scratch) and I end up in some problems in compiling.
I just don't know what's te problem. I even compared my widget with the
Qt's example analogclock, everything seems the same....
Here is the code and the make output
.h
Code:
#ifndef PTEMPLATE_H #define PTEMPLATE_H #include <QWidget> #include <QColor> #include <QVariant> { Q_OBJECT Q_PROPERTY (bool EqualLeads READ EqualLeads WRITE setEqualLeads) Q_PROPERTY (int FirstLeadLength READ FirstLeadLength WRITE setFirstLeadLength) public: bool EqualLeads() const {return curEqualLeads;} void setEqualLeads(bool newValue); int FirstLeadLength() const {return curFirstLeadLength;}; void setFirstLeadLength(int newLeadLength); private: QVariant curValue; bool curEqualLeads; int curFirstLeadLength; } #endif
.cpp
Code:
#include <QtGui> #include "templateqt4.h" { setEqualLeads(true); setFirstLeadLength(10); resize(minimumSizeHint()); } { return minimumSizeHint(); } { } /***************************************************/ /* PROPERTY HANDLERS */ /***************************************************/ void PTemplate::setEqualLeads(bool newValue) { if (curEqualLeads != newValue) { curEqualLeads = newValue; update(); } } void PTemplate::setFirstLeadLength(int newLeadLength) { if (curFirstLeadLength != newLeadLength) { curFirstLeadLength = newLeadLength; update(); } } /* END PROPERTY HANDLERS */
main.cpp
Code:
#include <QApplication> #include "templateqt4.h" int main(int argc, char *argv[]) { PTemplate *temp = new PTemplate; temp->show(); return app.exec(); }
make output
Than I tried to comment the lines fromQuote:
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o main.o main.cpp
main.cpp:5: error: new types may not be defined in a return type
main.cpp:5: note: (perhaps a semicolon is missing after the definition of ‘PTemplate’)
main.cpp:5: error: two or more data types in declaration of ‘main’
main.cpp:5: error: ‘::main’ must return ‘int’
make: *** [main.o] Error 1
the main.cpp that create the widget, so
that I can see the errors from the widget
main.cpp
Code:
#include <QApplication> //#include "templateqt4.h" int main(int argc, char *argv[]) { // PTemplate *temp = new PTemplate; // temp->show(); return app.exec(); }
make output
I use qt 4.1.2 with gcc 4.0Quote:
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o main.o main.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o templateqt4.o templateqt4.cpp
templateqt4.cpp:6: error: new types may not be defined in a return type
templateqt4.cpp:6: note: (perhaps a semicolon is missing after the definition of ‘PTemplate’)
templateqt4.cpp:6: error: return type specification for constructor invalid
make: *** [templateqt4.o] Error 1
Any Ideas are welcomed. Probably is some stupid
mestake, that I just can't see it :confused:
GREETZ, chombium