Unsolved gotnewmessage() signal does not emit after sendmessage() signal
-
@Christian-Ehrlicher ok I have corrected that. Can you please tell me why gotnewmessage() is not working after sendmessage() signal is emmited from windows class?
-
Hi,
@fari35 said in gotnewmessage() signal does not emit after sendmessage() signal:
class fserver : public QTcpServer,public threadobj
Why the double heritage ?
-
@SGaist because I want to use the same object of fthread class in both the server and mainwindow class
-
This is not how it works. Please check the threaded fortune server example if you really want to use threads.
In any case, the way you use multiple inheritance is wrong.
-
@SGaist Actually that's not the problem. The problem is that it is emitting gotnewmessage() signal until I don't click send button in mainwindow class to emit sendmessage() signal, but once sendmessage() signal is emmitted gotnewmessage() signal doesn't emit
-
That will be part of the problem at some point because it makes your code messy.
In any case, you have an issue with the socket creation as it's not done in the correct thread.
You should really clean your implementation. It will make your code easier to manage and debug.
-
This post is deleted! -
This post is deleted! -
@SGaist ohh I just figured out once sendmessage() signal is emitted from mainwindow class then the readyread() function is not executed in fthread class. But why is that so?
-
Because there's no reason for that to happen. You just connected a signal to another signal.
Excuse me for being blunt but: your current code is a mess. Your architecture is wrong on several levels. You seem to want some kind of threaded server inside a GUI while also making it its own client but without any connection.
As I already suggested, if you really want to use threads (and you really don't at this stage), read the threaded fortune server example.
Keep things clearly separated. Have one server component, then build your GUI to use that component. Look for aggregation VS inheritance.