本文整理汇总了C++中QTextEdit::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::clear方法的具体用法?C++ QTextEdit::clear怎么用?C++ QTextEdit::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextEdit
的用法示例。
在下文中一共展示了QTextEdit::clear方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: file
void
CSAVE_WORKSHEET::
saveWorksheet(QTabWidget * tabWidget)
{
QTextEdit * textEdit = new QTextEdit();
QString fileName = QFileDialog::getSaveFileName(this,tr("Save PM Worksheet"), "",tr("PM Worksheet (*.pmw);;All Files (*)"));
textEdit->clear();
textEdit->hide();
if (fileName.isEmpty())
return;
else
{
QFile file(fileName);
QTextStream out(&file);
if (!file.open(QIODevice::WriteOnly))
{
QMessageBox::information(this, tr("Unable to open file"),file.errorString());
return;
}
for ( int i = 0; i < tabWidget->count(); i++ )
{
tabWidget->setCurrentIndex(i); // set to Master PM
QTableWidget *table = dynamic_cast<QTableWidget *>(tabWidget->currentWidget()); // get control
QString itemData;
textEdit->append("[ SECTION ] "+tabWidget->tabText(i));
for ( int j = 0; j < table->rowCount(); j++ )
{
for ( int k = 0; k < 12; k++ )
{
itemData.append(table->item(j,k)->text()+" | ");
}
textEdit->append(itemData.trimmed());
itemData.clear();
}
out << textEdit->toPlainText() << endl;
textEdit->clear();
}
}
tabWidget->setCurrentIndex(2);
QMessageBox::information(this, "Information", "\n Saved worksheet successfully.", QMessageBox::Ok);
}
示例2: on_listWidgetFormats_currentItemChanged
void ClipboardDialog::on_listWidgetFormats_currentItemChanged(
QListWidgetItem *current, QListWidgetItem *)
{
ui->actionRemove_Format->setEnabled(current != NULL);
QTextEdit *edit = ui->textEditContent;
QString mime = current ? current->text() : QString();
edit->clear();
const QByteArray bytes = m_data.value(mime).toByteArray();
if ( mime.startsWith(QString("image")) ) {
edit->document()->addResource( QTextDocument::ImageResource,
QUrl("data://1"), bytes );
edit->setHtml( QString("<img src=\"data://1\" />") );
} else {
QTextCodec *codec = QTextCodec::codecForName("utf-8");
if (mime == QLatin1String("text/html"))
codec = QTextCodec::codecForHtml(bytes, codec);
else
codec = QTextCodec::codecForUtfText(bytes, codec);
edit->setPlainText( codec ? codec->toUnicode(bytes) : QString() );
}
ui->labelProperties->setText(
tr("<strong> mime:</strong> %1 <strong>size:</strong> %2 bytes")
.arg(escapeHtml(mime))
.arg(QString::number(bytes.size())));
}
示例3: clearErrors
void ExplorerPane::clearErrors()
{
QTextEdit *errorWidget = dynamic_cast<QTextEdit *>(errorsPage);
if (errorWidget)
{
errorWidget->clear();
}
}
示例4: clearSimulator
void ExplorerPane::clearSimulator()
{
// Output page
QTextEdit *outputWidget = dynamic_cast<QTextEdit *>(outputPage);
if (outputWidget)
{
outputWidget->clear();
}
}
示例5: clearTab
/**
* Clears text from the currently selected tab
* @brief MainWindow::clearTab
*/
void MainWindow::clearTab()
{
if(ui->tabgrpConversations->currentIndex() == 0)
ui->txtConvo->clear();
else
{
QTextEdit* txtConv = ui->tabgrpConversations->currentWidget()->findChild<QTextEdit*>(CONVO_TAB_TXT_ID);
txtConv->clear();
}
}
示例6: sendConvoMessage
/**
* Gets the conversation corresponding to the
* currently selected tab, and sends whatever's in its
* message text-box to all participants of the conversation.
* @brief MainWindow::sendConvoMessage
*/
void MainWindow::sendConvoMessage()
{
Conversation *cdata = convos->at(ui->tabgrpConversations->currentIndex()-1);
QTextEdit* txtMsg = ui->tabgrpConversations->currentWidget()->findChild<QTextEdit*>(CONVO_TAB_MSG_ID);
QTextEdit* txtConv = ui->tabgrpConversations->currentWidget()->findChild<QTextEdit*>(CONVO_TAB_TXT_ID);
if(txtMsg->toPlainText().length() > 0)
{
controller->sendConvoMessage(cdata, txtMsg->toPlainText());
addTextToConvo(txtConv, controller->myName() + "|" + txtMsg->toPlainText());
txtMsg->clear();
}
}
示例7: slotDeleteShip
//слот - удаление корабля
void MyServer::slotDeleteShip(){
//считываем номер текущей страницы
//(номер удаляемого корабля)
int num = logNumber->text().toInt();
//получаем адрес лога удаляемого корабля
QTextEdit *txt = (QTextEdit*) txtStack->widget(num-1);
int idOfDeleted = shipList.at(num-1)->id;
//удаляем корабль из вектора
shipList.remove(num-1);
shipCounter--;
//если это был последний корабль
if(shipCounter==0){
txt->clear(); //очищаем лог
deleteShipButton->setEnabled(false); //отключаем кнопку удаления
}
//иначе
else{
txtStack->removeWidget(txt); //удаляем лог
if(num > shipCounter){ //если номер лога больше количества кораблей
logNumber->setText(QString::number(num-1)); //обновляем номер
txtStack->setCurrentIndex(num-2);
}
else{
txtStack->setCurrentIndex(num-1);
}
delete txt;
}
//если в итоге оказались на первом логе
if(!txtStack->currentIndex()){
prevButton->setEnabled(false);
}
//если в итоге оказались на последнем логе
if((txtStack->currentIndex()+1)==shipCounter){
nextButton->setEnabled(false);
}
messageLabel->setText(QString("Ship (ID: %1) - deleted").arg(idOfDeleted+1));
logNumbersOfRemovedShips.append(num); //добавить в список номер лога удаленного корабля
}
示例8: editMenuActivated
void editMenuActivated(QAction *action)
{
QWidget* w = qApp->focusWidget();
QTextEdit* te = qobject_cast<QTextEdit*>(w);
QLineEdit* le = qobject_cast<QLineEdit*>(w);
if (action == selectAction) {
highlighting = this;
return;
}
highlighting = 0;
if (action == copyAction) {
if (te) {
if (te->hasEditFocus()) {
te->copy();
} else {
QTextCursor c = te->textCursor();
te->selectAll();
te->copy();
te->setTextCursor(c); // reset selection
}
} else if (le) {
if (le->hasEditFocus()) {
le->copy();
} else {
qApp->clipboard()->setText(le->text());
}
}
} else if (action == pasteAction) {
// assumes clipboard is not empty if 'Paste' is able to be
// activated, otherwise the line/textedit might be cleared
// without pasting anything back into it
if (te) {
if (!te->hasEditFocus())
te->clear();
te->paste();
if (!te->hasEditFocus()) {
te->moveCursor(QTextCursor::Start);
te->ensureCursorVisible();
}
} else if (le) {
if (!le->hasEditFocus())
le->clear();
le->paste();
if (!le->hasEditFocus())
le->home(false);
}
}
}
示例9: QTextEdit
void
CSAVE_WORKSHEET::
updateMasterPm( QTabWidget * tabWidget)
{
QTextEdit * textEdit = new QTextEdit();
textEdit->clear();
textEdit->hide();
tabWidget->hide();
// reset tab3 row count
tabWidget->setCurrentIndex(3);
QTableWidget * table3 = dynamic_cast<QTableWidget *>(tabWidget->currentWidget());
table3->setRowCount(0);
for ( int i = 0; i < tabWidget->count()-1; i++ )
{
tabWidget->setCurrentIndex(i);
QTableWidget *table = dynamic_cast<QTableWidget *>(tabWidget->currentWidget()); // get control
for ( int j = 0; j < table->rowCount(); j++ )
{
QString itemData;
for ( int k = 0; k < 12; k++ )
itemData.append(table->item(j,k)->text().trimmed().toLatin1()+" | ");
table3->insertRow(table3->rowCount());
for ( int col = 0; col < 12; col++ )
{
QTableWidgetItem * item = new QTableWidgetItem(itemData.split("|").at(col).trimmed());
if ( col == 0 )
item->setTextAlignment(Qt::AlignVCenter | Qt::AlignLeft);
else
item->setTextAlignment(Qt::AlignCenter);
item->setFlags(item->flags() & ~Qt::ItemIsEditable);
table3->setItem(table3->rowCount()-1,col,item);
}
}
}
tabWidget->show();
}
示例10: on_listWidgetFormats_currentItemChanged
void ClipboardDialog::on_listWidgetFormats_currentItemChanged(
QListWidgetItem *current, QListWidgetItem *)
{
ui->actionRemove_Format->setEnabled(current != NULL);
QTextEdit *edit = ui->textEditContent;
QString mime = current ? current->text() : QString();
edit->clear();
const QByteArray bytes = m_data.value(mime).toByteArray();
if ( mime.startsWith(QString("image")) ) {
edit->document()->addResource( QTextDocument::ImageResource,
QUrl("data://1"), bytes );
edit->setHtml( QString("<img src=\"data://1\" />") );
} else {
edit->setPlainText( dataToText(bytes, mime) );
}
ui->labelProperties->setText(
tr("<strong>Size:</strong> %1 bytes", "Size of data in bytes").arg(bytes.size()) );
}