[SOLVED] qtcpserver and qmainwindow on the constructor
-
I have this server project that i am trying to create a form for it. in the mainwindow construction i have Qmainwindow as parent. the problems is that the tcpserver commands do not work now. i set the QTcpServer in the constructor as in the code below. now i am getting a bunch of errors. how to put the QTcpServer and the Qmainwindow on the constructor line without getting any errors. is this possible? do i need to put something into the header?
@class ChatterBoxServer : public QTcpServer, public QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),QTcpServer(parent),@ -
You are trying to multiple inherit from two QObjects. That is not going to work for a whole bunch of reasons. The most important thing is the design choice though. Your main window has no business being a server. If it controls one, it should have a server.
-
Kalster , you have already raised a question regarding this. Please check the work around i have posted in your other "thread":http://developer.qt.nokia.com/forums/viewthread/9006/.
-
That is not the same question, if you ask me.
kalster, what Frankz and octal are trying to tell you, is that you should not do this:
@
class ChatterBoxServer : public QTcpServer, public QMainWindowMainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),QTcpServer(parent)
@but should instead do something like this:
@
class ChatterBoxServer : public QTcpServer
{
//...
}class ChatterBoxServerUi: public QMainWindow
{
public:
ChatterBoxServerUi (ChatterBoxServer* server, QWidget* parent=0);
//...private:
ChatterBoxServer* m_server;
}
@That is: your ChatterBoxServer class is a subclass of just QTcpServer, and your UI for it is a subclass of QMainWindow that in its constructor (or in some other way) takes a pointer to an instance of a ChatterBoxServer instance.
-
[quote author="Rahul Das" date="1313916068"]Kalster , you have already raised a question regarding this. Please check the work around i have posted in your other "thread":http://developer.qt.nokia.com/forums/viewthread/9006/.[/quote]
Rahul Das is correct. i really do not need this topic anymore because he helped me out in the other topic. he basically solved two topics in one post.