Results 1 to 3 of 3

Thread: Accessing QTextEdit

  1. #1
    Join Date
    May 2007
    Location
    Germany
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Accessing QTextEdit

    Hello friends,

    how can I access my QTexEdit from another class or from a Thread.

    Qt Code:
    1. thr_startReadTrackFile = new readTrackFile(selectedFile, bodyEdit);
    2. thr_startReadTrackFile->start();
    To copy to clipboard, switch view to plain text mode 

    when I append a line to the TextEdit in my Thread I have an Error .....

    my Thread declaration looks like
    Qt Code:
    1. //**************************************************************************
    2. class readTrackFile : public QThread
    3. //**************************************************************************
    4. {
    5. Q_OBJECT
    6. public:
    7. readTrackFile(const QString &p_inFile,
    8. QTextEdit *p_bodyEditCopy,
    9. QObject* parent = 0);
    10. virtual ~readTrackFile() { }
    11.  
    12. public slots:
    13. protected:
    14. void run();
    15. private:
    16. QString qstr_inFile;
    17. QTextEdit* bodyEditCopy;
    To copy to clipboard, switch view to plain text mode 

    and in the implemantion

    Qt Code:
    1. void readTrackFile::run()
    2. {
    3. ...
    4.  
    5. QFile inFile(qstr_inFile);
    6. QString qstr_textLine;
    7.  
    8. if(inFile.exists() )
    9. {
    10. if (inFile.open(QFile::ReadOnly | QFile::Text) )
    11. {
    12. QTextStream filestream( &inFile );
    13.  
    14. ...
    15. while (!filestream.atEnd())
    16. {
    17. qstr_textLine = filestream.readLine();
    18. if(qstr_textLine.count(";",Qt::CaseInsensitive)== 36)
    19. {
    20. bodyEditCopy->append(qstr_textLine);
    21.  
    22. ...
    23. }
    24. else
    25. {
    26. ...
    27. ...
    28. ...
    29. }
    30. }
    31. }
    32. }
    33. inFile.close();
    34. }
    To copy to clipboard, switch view to plain text mode 

    Could anybody see the misunderstanding from my side....

  2. #2
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Accessing QTextEdit

    You can not change the GUI from the Non-GUI thread, most of the time you will get crash if you do. Use signals and slots in order to update the GUI when something happens in to the thread.

  3. #3
    Join Date
    May 2007
    Location
    Germany
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Accessing QTextEdit

    hmmm.... ok thx for your help my friend

    cu

Similar Threads

  1. QTextEdit Performance handling large paragraphs
    By netuno in forum Qt Programming
    Replies: 14
    Last Post: 1st September 2010, 22:58
  2. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 12:05
  3. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 06:03
  4. [QT 4] QTextEdit performance
    By fellobo in forum Qt Programming
    Replies: 8
    Last Post: 6th March 2006, 19:27
  5. Painting to QTextEdit
    By gesslar in forum Qt Programming
    Replies: 8
    Last Post: 18th February 2006, 18:40

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.