PDA

View Full Version : Question



Dumbledore
17th October 2007, 00:00
I have a class derived from TcpSocket. From a method in this class I want to assign some text to a QTextBrowser. What's the best way to do that?

Also is this okay? To get access to those generated objects from my class that derives from QMainWindow I am inheriting Ui::GeneratedClass.



class MChat : public QMainWindow, private Ui::MChat {


With this I can get access to QTextBrowser::append()

but this:



class MSocket : public QTcpSocket, private Ui::MChat


Will not.

wysota
20th October 2007, 23:12
Why should a socket inherit your user interface? You need to provide a way to access the text browser from within a separate object, for instance by providing the textBrowser() method to MChat class that will return a pointer to the text browser object or by using signals and slots to connect a signal from the socket class (which you have to emit yourself of course) to a slot in the text browser that will append the text.