probine
23rd March 2006, 09:04
Using Qt-4.1.1.
I have looked at the documentation, and there is an exameple on how to create a thread inheriting from QThread. The problem is that I cannot see how to apply the example in this class:
_______________________________________________--
# Server.h
# ifndef SERVER_H
# define SERVER_H
# include <QObject>
# include "ServerGUI.h"
class Server : public QObject
{
Q_OBJECT
private:
public:
void run();
public slots:
void new_client();
};
# endif
________________________________________________--
# Server.cpp
# include <iostream>
# include "Server.h"
Server :: Server()
{
};
void Server :: new_client()
{
std::cout << "New client connected\n";
}
void Server :: run()
{
std::cout << "Thread running\n";
QThread::start(QThread::NormalPriority=QThread::In heritPriority);
}
_______________________________________________-
There is some more code about connecting the server and so on, but is not relevant now.
How do I start the thread ?
I have looked at the documentation, and there is an exameple on how to create a thread inheriting from QThread. The problem is that I cannot see how to apply the example in this class:
_______________________________________________--
# Server.h
# ifndef SERVER_H
# define SERVER_H
# include <QObject>
# include "ServerGUI.h"
class Server : public QObject
{
Q_OBJECT
private:
public:
void run();
public slots:
void new_client();
};
# endif
________________________________________________--
# Server.cpp
# include <iostream>
# include "Server.h"
Server :: Server()
{
};
void Server :: new_client()
{
std::cout << "New client connected\n";
}
void Server :: run()
{
std::cout << "Thread running\n";
QThread::start(QThread::NormalPriority=QThread::In heritPriority);
}
_______________________________________________-
There is some more code about connecting the server and so on, but is not relevant now.
How do I start the thread ?