Results 1 to 2 of 2

Thread: Question

  1. #1
    Join Date
    Oct 2007
    Posts
    38
    Thanks
    1

    Default Question

    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.

    Qt Code:
    1. class MChat : public QMainWindow, private Ui::MChat {
    To copy to clipboard, switch view to plain text mode 

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

    but this:

    Qt Code:
    1. class MSocket : public QTcpSocket, private Ui::MChat
    To copy to clipboard, switch view to plain text mode 

    Will not.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Question

    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.

Similar Threads

  1. Access to QSqlTableModel::isDirty Question.
    By patrik08 in forum Qt Programming
    Replies: 3
    Last Post: 12th April 2007, 18:49
  2. Replies: 1
    Last Post: 15th March 2007, 21:45
  3. Question regarding how to paint after zoom.
    By JonathanForQT4 in forum Qt Programming
    Replies: 2
    Last Post: 26th January 2007, 16:34
  4. QThread exit()/quit() question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2006, 15:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.