What happens if you include QObject and make Jaus_neighbor a subclass of QObject?
What happens if you include QObject and make Jaus_neighbor a subclass of QObject?
Misha R.evolution - High level Debugging IDE
Programming is about 2 basic principles: KISS and RTFM!!!
Now I get an error saying multiple constructors defined:
multiple definition of `Jaus_neighbor::Jaus_neighbor()
Qt Code:
Jaus_neighbor::Jaus_neighbor() { for (int i = 0; i < 4; i++) { head.dest_id[i] = 0; head.source_id[i] = 0; } head.sequence_num = 0; head.data_control = 0; head.message_properties = 0; head.command_code = NULL; }To copy to clipboard, switch view to plain text mode
Nevermind - I commented out the default constructor and I get the same error
I was getting the same error with a custom table model (but only one out of 5, go figure).
Try the following:
1) See if it compiles correctly if you take out the Q_OBJECT define (and you may want to comment out the signals and slots as well).
2) If it compiles, then the moc compiler could be causing problems, so see if the following fixes it:
a) Specify CONFIG += release in the pro file.
b) Put the destructor definition in the header file (ie. ~MyClass(){})
This worked for me compiling with Qt 4.5.3. If you want to build debug as well just change CONFIG += release build_all -> this builds the release version first, then the debug version, which seems to help.
EDIT: I forgot to add that Jaus_neighbor must inherit from QObject.
Last edited by bmhautz; 24th February 2010 at 21:15.
commented it out and i still get the same error
Post the last version of the code of jaus.h and jaus.cpp
Misha R.evolution - High level Debugging IDE
Programming is about 2 basic principles: KISS and RTFM!!!
It may be useful to post updated code with a note of what changed and the specific errors you are getting.
Here's my updated code:
Qt Code:
#ifndef JAUS_H #define JAUS_H #include <QtNetwork> #include <QUdpSocket> #include <QObject> struct Jaus_header { unsigned short message_properties; unsigned short command_code; unsigned short data_control; unsigned short sequence_num; }; { Q_OBJECT public: void handshake(); void capabilities_discover(); void sys_management(); void close_conn(); private: Jaus_header head; QUdpSocket *udpSocket; private slots: Jaus_neighbor(); void prepare_header(); void read_jheader(); void send_jheader(); void do_command(); void startBroadcasting(); void stopBroadcasting(); void sendDatagram(); //void verifyDatagram(); }; #endif // JAUS_HTo copy to clipboard, switch view to plain text mode
Qt Code:
#include "jaus.h" Jaus_neighbor::Jaus_neighbor() { for (int i = 0; i < 4; i++) { head.dest_id[i] = 0; head.source_id[i] = 0; } head.sequence_num = 0; head.data_control = 0; head.message_properties = 0; head.command_code = 0; } void Jaus_neighbor::startBroadcasting() { } void Jaus_neighbor::stopBroadcasting() { } void Jaus_neighbor::sendDatagram() { //udpSocket->writeDatagram(message, QHostAddress::LocalHost, 9000); } void Jaus_neighbor::handshake() { Jaus_neighbor::startBroadcasting(); }To copy to clipboard, switch view to plain text mode
Qt Code:
#include <QtCore/QCoreApplication> #include <iostream> #include "jaus.h" using namespace std; int main(int argc, char *argv[]) { cout << "Initializing Jaus Connections..." << flush; //Jaus_neighbor cop; return a.exec(); }To copy to clipboard, switch view to plain text mode
I'm still getting the warnings -- but more importantly I think, is I'm getting the following error also: error: collect2: ld returned 1 exit status
If I comment out my default constructor, the app compiles fine.
You have your constructor in private slots, that means when you declare an Jaus_neighbor object you can't access the constructor cause it's private. So move it to public.
Also you're getting undefined references for the functions prepare_header(), read_jheader(), send_jheader() and do_command() because there aren't implementation for those functions in the jaus.cpp.
Misha R.evolution - High level Debugging IDE
Programming is about 2 basic principles: KISS and RTFM!!!
Thanks for the info -- I moved the constructor to public: but I still get the same error
I copy pasted the code you gave. I moved the constructor to public, provided the implementation for the functions I told in the previous post ( put in the .cpp file eg.
void Jaus_neighbor:repare_header() {} and so on) and compiled with success!
Misha R.evolution - High level Debugging IDE
Programming is about 2 basic principles: KISS and RTFM!!!
well that's just not fair then!
here's my new .cpp file (and i moved the constructor):
Qt Code:
#include "jaus.h" Jaus_neighbor::Jaus_neighbor() { for (int i = 0; i < 4; i++) { header.dest_id[i] = 0; header.source_id[i] = 0; } header.sequence_num = 0; header.data_control = 0; header.message_properties = 0; header.command_code = 0; } void Jaus_neighbor::startBroadcasting() { } void Jaus_neighbor::stopBroadcasting() { } void Jaus_neighbor::sendDatagram() { //udpSocket->writeDatagram(message, QHostAddress::LocalHost, 9000); } void Jaus_neighbor::handshake() { Jaus_neighbor::startBroadcasting(); } void Jaus_neighbor::prepare_header(){} void Jaus_neighbor::read_jheader(){} void Jaus_neighbor::send_jheader(){} void Jaus_neighbor::do_command(){}To copy to clipboard, switch view to plain text mode
Same error though![]()
What are the differences with the code you'll find in the .zip??
Also did you rerun qmake?
Misha R.evolution - High level Debugging IDE
Programming is about 2 basic principles: KISS and RTFM!!!
Bookmarks