Results 1 to 17 of 17

Thread: QTextEdit -> add Text

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2007
    Posts
    33
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default QTextEdit -> add Text

    Hello

    i am new to Qt itself and playing around with the examples.
    At the moment i am trying to build a small RS232 flash application.

    The idea was to have a scrollable TextField which should be used to log each action
    forced by the user.

    So i have added a QTextedit (scrollable and offers the option to make it readonly...great)
    Now my problem is as follows:

    Each time i am trying to add new text to that QTextEdit the complete application crashes.

    i.e. in the OpenFile Dialog (dummy Style righrt now)
    Qt Code:
    1. void MainWindow::openFileDialog()
    2. {
    3. // Dummy File select dialog
    4. // Method 1: Limit location and limit file-types
    5. QString fileName = QFileDialog::getOpenFileName(this, tr("Select Firmware"),
    6. "/",
    7. tr("All (*.*)"));
    8.  
    9. // Now we want to add an entry into our logging QTextEdit at the Main window)
    10. // this idea results in a crash
    11. loggingBox->setText("open file dialog was selected")
    12. //
    13. // Trying something diffrent ....just clearing the text inside Logging Box
    14. // this idea results in a crash too
    15. loggingBox->clear();
    16. }
    To copy to clipboard, switch view to plain text mode 


    in the main section....how i call the function above
    Qt Code:
    1. selectFileButton = new QPushButton(handleFlashBox); // new QPushButton
    2. selectFileButton->setGeometry(QRect(12,25,100,20));
    3. selectFileButton->setStatusTip(QString::fromUtf8("Press Select to choose the new firmware."));
    4. selectFileButton->setToolTip(QString::fromUtf8("Press SELECT to choose the new firmware."));
    5. connect(selectFileButton, SIGNAL(clicked()), this, SLOT(openFileDialog()));
    To copy to clipboard, switch view to plain text mode 

    Any idea what i am doing wrong ?

    do i have to save the existing text in a string variable first, then add the new text-part to that string and then insert the string-content to my loggingBox maybe ?

    Based on a search in the mailinglist someone posted this idea:
    Qt Code:
    1. textedit->setText( textedit->text() + "some more text" );
    2. // in my case
    3. loggingBox->setText( loggingBox->text() + "new text");
    4. // but seems like QTextEdit has no member named 'text'
    To copy to clipboard, switch view to plain text mode 

    Best regards
    ape
    Last edited by ape; 18th December 2007 at 10:02.

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 14:36
  3. Replies: 3
    Last Post: 20th November 2007, 07:03
  4. How to get text of last line only in QTextEdit?
    By rajesh in forum Qt Programming
    Replies: 2
    Last Post: 12th June 2006, 13:37
  5. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 06:03

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.