本文整理汇总了C++中QTextEdit类的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit类的具体用法?C++ QTextEdit怎么用?C++ QTextEdit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTextEdit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
void ctkCmdLineModuleExplorerShowXmlAction::run()
{
QDialog* dialog = new QDialog();
try
{
dialog->setWindowTitle(this->ModuleRef.description().title());
}
catch (const ctkCmdLineModuleXmlException&)
{
dialog->setWindowTitle(this->ModuleRef.location().toString());
}
dialog->setLayout(new QVBoxLayout());
QHBoxLayout* buttonLayout = new QHBoxLayout();
buttonLayout->addStretch(1);
QPushButton* closeButton = new QPushButton(tr("Close"), dialog);
buttonLayout->addWidget(closeButton);
QTextEdit* textEdit = new QTextEdit(dialog);
textEdit->setPlainText(this->ModuleRef.rawXmlDescription().data());
QLabel* statusLabel = new QLabel(dialog);
statusLabel->setWordWrap(true);
if (this->ModuleRef.xmlValidationErrorString().isEmpty())
{
statusLabel->setText(tr("No validation errors."));
}
else
{
statusLabel->setText(this->ModuleRef.xmlValidationErrorString());
}
dialog->layout()->addWidget(statusLabel);
dialog->layout()->addWidget(textEdit);
dialog->layout()->addItem(buttonLayout);
connect(closeButton, SIGNAL(clicked()), dialog, SLOT(close()));
dialog->resize(800, 600);
dialog->show();
}
示例2: QWidget
void UpgradeMessage::createPage034 ()
{
QWidget *w = new QWidget(this);
QVBoxLayout *vbox = new QVBoxLayout(w);
vbox->setMargin(5);
vbox->setSpacing(5);
QString s = tr("Your workspace will be converted into the ~/.qtstalker/data1/ directory.");
s.append(tr(" It could take a long time if there are many data items."));
s.append(tr(" When satisfied, the old workspace can be manually removed from ~/.qtstalker/data0/\n"));
s.append(tr("\n"));
s.append(tr(" If you choose Cancel, then Quit immediately and see the cleanup notes in docs/install.html"));
QTextEdit *message = new QTextEdit(w);
message->setReadOnly(TRUE);
message->setText(s);
vbox->addWidget(message);
QHBoxLayout *hbox = new QHBoxLayout(vbox);
hbox->setSpacing(2);
QLabel *label = new QLabel(tr("Progress"), w);
hbox->addWidget(label);
progBar = new QProgressBar(w);
hbox->addWidget(progBar);
addTab(w, tr("Chart Conversion"));
QPushButton *button = new QPushButton(tr("Perform Conversion"), w);
QObject::connect(button, SIGNAL(clicked()), this, SLOT(convert034()));
vbox->addWidget(button);
vbox->addStretch(1);
setOkButton(QString::null);
setCancelButton(tr("&Cancel"));
resize(500, 300);
}
示例3:
void
QUimTextUtil::QTextEditPositionForward( int *cursor_para, int *cursor_index )
{
QTextEdit *edit = (QTextEdit *)mWidget;
int n_para = edit->paragraphs();
int preedit_len, preedit_cursor_pos;
int current_para_len;
int para, index;
int current_para, current_index;
current_para = *cursor_para;
current_index = *cursor_index;
current_para_len = edit->paragraphLength( current_para );
if ( ! mPreeditSaved ) {
preedit_len = mIc->getPreeditString().length();
preedit_cursor_pos = mIc->getPreeditCursorPosition();
} else {
preedit_len = 0;
preedit_cursor_pos = 0;
}
edit->getCursorPosition( ¶, &index );
if ( current_para == para && current_index >= ( index - preedit_cursor_pos ) && current_index < ( index - preedit_cursor_pos + preedit_len ) )
current_index = index - preedit_cursor_pos + preedit_len;
if ( current_para == n_para - 1 ) {
if ( current_index < current_para_len )
current_index++;
} else {
if ( current_index < current_para_len )
current_index++;
else {
current_para++;
current_index = 0;
}
}
*cursor_para = current_para;
*cursor_index = current_index;
}
示例4: updateMasterPm
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();
}
示例5: QUrl
bool GCF::Components::AboutBox::eventFilter(QObject* obj, QEvent* event)
{
if(!obj->isWidgetType())
return false;
if(event->type() != QEvent::MouseButtonPress)
return false;
QWidget* wid = (QWidget*)obj;
QTextEdit* te = qobject_cast<QTextEdit*>(wid->parentWidget());
if(!te)
return false;
QMouseEvent* me = (QMouseEvent*)event;
QString anchor = te->anchorAt(me->pos());
if(anchor.isEmpty())
return false;
QDesktopServices::openUrl( QUrl(anchor) );
return false;
}
示例6: getCurrentSourceEdit
void SourceViewer::onSelectionChanged()
{
if(workingHighlightText_)
return;
if(gGlobalEvent.isMousePressed() == true)
return;
QTextEdit *logTextEdit = getCurrentSourceEdit();
if(logTextEdit != NULL)
{
QString s = logTextEdit->textCursor().selectedText();
if(s.isEmpty() == false && s.length() < 50)
{
qDebug() << "onLogSelectionChanged : " << gGlobalEvent.isMousePressed() << s;
ui.searchText->setText(s);
}
}
}
示例7: setModelData
void DelegateDoubleItem::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
QTextEdit *textEdit = static_cast<QTextEdit*>(editor);
QString data = textEdit->toPlainText();
data.replace( "m","e-3" );
data.replace( "u", "e-6" );
data.replace("n","e-9");
data.replace("p","e-12");
data.replace("f","e-15");
data.replace("K","e3");
data.replace("M","e6");
data.replace("G","e9");
data.replace("T","e12");
double prevData = model->data(index,Qt::EditRole).toDouble();
bool ok;
double value = data.toDouble(&ok);
if(!ok) value = prevData;
model->setData(index,value,Qt::EditRole);
}
示例8: style
void PsiTipLabel::initUi()
{
margin = 1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this);
setFrameStyle(QFrame::NoFrame);
// doc = new QTextDocument(this);
// QTextDocumentLayout is private in Qt4
// and it's impossible to set wrapping mode directly.
// So we create this QTextEdit instance and use its QTextDocument,
// just because QTextEdit can set the wrapping mode.
// Yes, this is crazy...
QTextEdit *edit = new QTextEdit(this);
edit->hide();
edit->setWordWrapMode(QTextOption::WordWrap);
doc = edit->document();
doc->setUndoRedoEnabled(false);
doc->setDefaultFont(font());
ensurePolished();
setText(theText_);
}
示例9: floor
void MainWindow::hamza(){
int hamza[9][9] = {
{ 0, 0, 0, 7, 0, 0, 8, 0, 0 },
{ 0, 0, 0, 0, 4, 0, 0, 3, 0 },
{ 0, 0, 0, 0, 0, 9, 0, 0, 1 },
{ 6, 0, 0, 5, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 3, 0, 0, 4, 0 },
{ 0, 0, 5, 0, 0, 1, 0, 0, 7 },
{ 5, 0, 0, 2, 0, 0, 6, 0, 0 },
{ 0, 3, 0, 0, 8, 0, 0, 9, 0 },
{ 0, 0, 7, 0, 0, 0, 0, 0, 2 }
};
QList<QTextEdit*> textEdits = centralWidget->findChildren<QTextEdit *>();
for(int i = 0; i < textEdits.count(); i++) {
int y = (int(floor(i / 3)) % 3) + (3 * floor(i / 27));
int x = (i % 3) + (3 * floor(i / 9)) - (9 * floor(i / 27));
QTextEdit * tile = textEdits.at(i);
QString s = QString::number(hamza[y][x]);
tile->setText(s);
}
}
示例10: lookupProfile
void EditProfileDialog::showEnvironmentEditor()
{
const Profile::Ptr info = lookupProfile();
KDialog* dialog = new KDialog(this);
QTextEdit* edit = new QTextEdit(dialog);
QStringList currentEnvironment = info->property<QStringList>(Profile::Environment);
edit->setPlainText( currentEnvironment.join("\n") );
dialog->setPlainCaption(i18n("Edit Environment"));
dialog->setMainWidget(edit);
if ( dialog->exec() == QDialog::Accepted )
{
QStringList newEnvironment = edit->toPlainText().split('\n');
_tempProfile->setProperty(Profile::Environment,newEnvironment);
}
dialog->deleteLater();
}
示例11: checkChat
void PeersDialog::checkChat()
{
/* if <return> at the end of the text -> we can send it! */
QTextEdit *chatWidget = ui.lineEdit;
std::string txt = chatWidget->toPlainText().toStdString();
if ('\n' == txt[txt.length()-1])
{
//std::cerr << "Found <return> found at end of :" << txt << ": should send!";
//std::cerr << std::endl;
if (txt.length()-1 == txt.find('\n')) /* only if on first line! */
{
/* should remove last char ... */
sendMsg();
}
}
else
{
//std::cerr << "No <return> found in :" << txt << ":";
//std::cerr << std::endl;
}
}
示例12: PBDialog
/**
* Constructor.
*
* @param message The error message to be displayed
* @param data The line of CSV data which triggered the error
* @param parent The parent widget, if any
*/
CSVErrorDialog::CSVErrorDialog(const QString &message, const QString &data, QWidget *parent)
: PBDialog("", parent)
{
vbox->addWidget(new QLabel(message, this));
vbox->addWidget(new QLabel(tr("Problematic row") + ":", this));
QTextEdit *dataBox = new QTextEdit(parent);
dataBox->setReadOnly(true);
#if defined(Q_WS_MAEMO_5)
QVariant ksProp = dataBox->property("kineticScroller");
QAbstractKineticScroller *ks = ksProp.value<QAbstractKineticScroller *>();
if (ks) {
ks->setEnabled(true);
}
#endif
dataBox->setLineWrapMode(QTextEdit::NoWrap);
dataBox->setPlainText(data);
vbox->addWidget(dataBox);
finishLayout(true, false);
}
示例13: setLayout
void EulaWidget::setupUi()
{
QVBoxLayout * vb = new QVBoxLayout;
setLayout(vb);
QTextEdit * plain = new QTextEdit(this);
plain->setReadOnly(true);
QFile file(":/text/license.txt");
file.open(QIODevice::ReadOnly | QIODevice::Text);
if (file.isOpen())
{
QByteArray ba = file.readAll();
file.close();
QString str = QString::fromUtf8(ba.data());
plain->setText(str);
}
vb->addWidget(plain);
}
示例14: 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()) );
}
示例15: find
void FindDialog::find(bool backwards)
{
QString text = m_find_string->text();
if (text.isEmpty()) {
return;
}
QTextDocument::FindFlags flags;
if (!m_ignore_case->isChecked()) {
flags |= QTextDocument::FindCaseSensitively;
}
if (m_whole_words->isChecked()) {
flags |= QTextDocument::FindWholeWords;
}
if (backwards) {
flags |= QTextDocument::FindBackward;
}
QTextEdit* document = m_documents->currentDocument()->text();
QTextCursor cursor = document->document()->find(text, document->textCursor(), flags);
if (cursor.isNull()) {
cursor = document->textCursor();
cursor.movePosition(!backwards ? QTextCursor::Start : QTextCursor::End);
cursor = document->document()->find(text, cursor, flags);
}
if (!cursor.isNull()) {
document->setTextCursor(cursor);
} else {
QMessageBox::information(this, tr("Sorry"), tr("Phrase not found."));
}
}