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)
void MainWindow::openFileDialog()
{
// Dummy File select dialog
// Method 1: Limit location and limit file-types
"/",
tr("All (*.*)"));
// Now we want to add an entry into our logging QTextEdit at the Main window)
// this idea results in a crash
loggingBox->setText("open file dialog was selected")
//
// Trying something diffrent ....just clearing the text inside Logging Box
// this idea results in a crash too
loggingBox->clear();
}
void MainWindow::openFileDialog()
{
// Dummy File select dialog
// Method 1: Limit location and limit file-types
QString fileName = QFileDialog::getOpenFileName(this, tr("Select Firmware"),
"/",
tr("All (*.*)"));
// Now we want to add an entry into our logging QTextEdit at the Main window)
// this idea results in a crash
loggingBox->setText("open file dialog was selected")
//
// Trying something diffrent ....just clearing the text inside Logging Box
// this idea results in a crash too
loggingBox->clear();
}
To copy to clipboard, switch view to plain text mode
in the main section....how i call the function above
selectFileButton
= new QPushButton(handleFlashBox
);
// new QPushButtonselectFileButton
->setGeometry
(QRect(12,
25,
100,
20));
selectFileButton
->setStatusTip
(QString::fromUtf8("Press Select to choose the new firmware."));
selectFileButton
->setToolTip
(QString::fromUtf8("Press SELECT to choose the new firmware."));
connect(selectFileButton, SIGNAL(clicked()), this, SLOT(openFileDialog()));
selectFileButton = new QPushButton(handleFlashBox); // new QPushButton
selectFileButton->setGeometry(QRect(12,25,100,20));
selectFileButton->setStatusTip(QString::fromUtf8("Press Select to choose the new firmware."));
selectFileButton->setToolTip(QString::fromUtf8("Press SELECT to choose the new firmware."));
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:
textedit->setText( textedit->text() + "some more text" );
// in my case
loggingBox->setText( loggingBox->text() + "new text");
// but seems like QTextEdit has no member named 'text'
textedit->setText( textedit->text() + "some more text" );
// in my case
loggingBox->setText( loggingBox->text() + "new text");
// but seems like QTextEdit has no member named 'text'
To copy to clipboard, switch view to plain text mode
Best regards
ape
Bookmarks