Results 1 to 5 of 5

Thread: Showing Output from external QThread on Local QTextEdit object (Qt 4, SuSe Linux 10)

  1. #1
    Join Date
    Feb 2006
    Posts
    25
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Showing Output from external QThread on Local QTextEdit object (Qt 4, SuSe Linux 10)

    I have a Gui app that contains a QTextEdit object. From this app I start a separate QThread. What is the best way, if possible, for the QThread to print messages to the QTextEdit on the main Gui app.

    Any help is greatly appreciated.

    Thanks in advanced.

  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: Showing Output from external QThread on Local QTextEdit object (Qt 4, SuSe Linux 10)

    Make your thread emit a signal with the text to be appended to the text edit and connect it to QTextEdit::append() slot.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Showing Output from external QThread on Local QTextEdit object (Qt 4, SuSe Linux 10)

    Make sure you use a queued connection.

  4. #4
    Join Date
    Feb 2006
    Posts
    25
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Showing Output from external QThread on Local QTextEdit object (Qt 4, SuSe Linux

    Thanks for the help guys. This really gives me an idea and how to get this done. I'll post how it went.

    Thanks again

  5. #5
    Join Date
    Feb 2006
    Posts
    25
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Showing Output from external QThread on Local QTextEdit object (Qt 4, SuSe Linux

    I was able to make this work by connecting the signal inside my thread to the textEdit box.

    eg:

    GUI APP:

    thread = new mythread();

    connect(thread, SIGNAL(mysignal(QString)), textEdit, SLOT(append(QString)), Qt::QueuedConnection);

    THREAD:

    mythread::send(QString str)
    {
    emit mysignal(str);
    }

    thanks for the help.
    Last edited by freak; 10th May 2006 at 23:49.

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.