当前位置: 首页>>代码示例>>C++>>正文


C++ QTextEdit::setAcceptRichText方法代码示例

本文整理汇总了C++中QTextEdit::setAcceptRichText方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::setAcceptRichText方法的具体用法?C++ QTextEdit::setAcceptRichText怎么用?C++ QTextEdit::setAcceptRichText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTextEdit的用法示例。


在下文中一共展示了QTextEdit::setAcceptRichText方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: file

LicenseDialog::LicenseDialog(QWidget *parent)
	:QDialog(parent, Qt::WindowCloseButtonHint)
{
	QFile file(QLatin1String(":/traceshark/LICENSE"));

	if (!file.open(QIODevice::ReadOnly))
		qDebug() << "Warning, could not read license!\n";

	QTextStream textStream(&file);
	QString text = textStream.readAll();

	QTextEdit *textEdit = new QTextEdit();
	textEdit->setAcceptRichText(false);
	textEdit->setPlainText(text);
	textEdit->setReadOnly(true);
	textEdit->setLineWrapMode(QTextEdit::NoWrap);

	QVBoxLayout *vlayout = new QVBoxLayout;
	setLayout(vlayout);
	vlayout->addWidget(textEdit);

	QHBoxLayout *hlayout = new QHBoxLayout;
	vlayout->addLayout(hlayout);
	hlayout->addStretch();

	QPushButton *button = new QPushButton(tr("OK"));
	hlayout->addWidget(button);

	hlayout->addStretch();
	setModal(true);
	updateSize();

	hide();
	tsconnect(button, clicked(), this, hide());
}
开发者ID:felipebetancur,项目名称:traceshark,代码行数:35,代码来源:licensedialog.cpp

示例2: QDialog

ShowTextDlg::ShowTextDlg(const QString &text, bool nonfile, bool rich, QWidget *parent)
	: QDialog(parent)
{
	Q_UNUSED(nonfile);

	setAttribute(Qt::WA_DeleteOnClose);

	QVBoxLayout *vb1 = new QVBoxLayout(this);
	vb1->setMargin(8);
	QTextEdit *te = new QTextEdit(this);
	te->setReadOnly(true);
	te->setAcceptRichText(rich);
	te->setText(text);

	vb1->addWidget(te);

	QHBoxLayout *hb1 = new QHBoxLayout;
	vb1->addLayout(hb1);
	hb1->addStretch(1);
	QPushButton *pb = new QPushButton(tr("&OK"), this);
	connect(pb, SIGNAL(clicked()), SLOT(accept()));
	hb1->addWidget(pb);
	hb1->addStretch(1);

	resize(560, 384);
}
开发者ID:AlekSi,项目名称:psi,代码行数:26,代码来源:showtextdlg.cpp

示例3: f

// FIXME: combine to common init function
ShowTextDlg::ShowTextDlg(const QString &fname, bool rich, QWidget *parent)
	: QDialog(parent)
{
	setAttribute(Qt::WA_DeleteOnClose);
	QString text;

	QFile f(fname);
	if(f.open(QIODevice::ReadOnly)) {
		QTextStream t(&f);
		while(!t.atEnd())
			text += t.readLine() + '\n';
		f.close();
	}

	QVBoxLayout *vb1 = new QVBoxLayout(this);
	vb1->setMargin(8);
	QTextEdit *te = new QTextEdit(this);
	te->setReadOnly(true);
	te->setAcceptRichText(rich);
	te->setText(text);

	vb1->addWidget(te);

	QHBoxLayout *hb1 = new QHBoxLayout;
	vb1->addLayout(hb1);
	hb1->addStretch(1);
	QPushButton *pb = new QPushButton(tr("&OK"), this);
	connect(pb, SIGNAL(clicked()), SLOT(accept()));
	hb1->addWidget(pb);
	hb1->addStretch(1);

	resize(560, 384);
}
开发者ID:AlekSi,项目名称:psi,代码行数:34,代码来源:showtextdlg.cpp

示例4: registerField

QWidget *CustomWizardFieldPage::registerTextEdit(const QString &fieldName,
                                                 const CustomWizardField &field)
{
    QTextEdit *textEdit = new QTextEdit;
    // Suppress formatting by default (inverting QTextEdit's default value) when
    // pasting from Bug tracker, etc.
    const bool acceptRichText = field.controlAttributes.value(QLatin1String("acceptRichText")) == QLatin1String("true");
    textEdit->setAcceptRichText(acceptRichText);
    // Connect to completeChanged() for derived classes that reimplement isComplete()
    registerField(fieldName, textEdit, "plainText", SIGNAL(textChanged()));
    connect(textEdit, SIGNAL(textChanged()), SIGNAL(completeChanged()));
    const QString defaultText = field.controlAttributes.value(QLatin1String("defaulttext"));
    m_textEdits.push_back(TextEditData(textEdit, defaultText));
    return textEdit;
} // QTextEdit
开发者ID:gs93,项目名称:qt-creator,代码行数:15,代码来源:customwizardpage.cpp

示例5: QDialog

DialogResourceText::DialogResourceText(QString text, QWidget *parent): QDialog(parent)
{
	setWindowTitle(tr("Resource Dialog"));
	
	QDialogButtonBox *dialogbuttonbox = new QDialogButtonBox(this);
	dialogbuttonbox->setOrientation(Qt::Horizontal);
	dialogbuttonbox->setStandardButtons(QDialogButtonBox::Ok);

	QTextEdit *textedit = new QTextEdit(this);
	textedit->setAcceptRichText(true);
	textedit->setText(text);

	QGridLayout *layout = new QGridLayout(this);
	layout->addWidget(textedit);
	layout->addWidget(dialogbuttonbox);

	connect(dialogbuttonbox, SIGNAL(accepted()), this, SLOT(accept()));
}
开发者ID:einfallstoll,项目名称:testapplication-qt5,代码行数:18,代码来源:DialogResourceText.cpp

示例6: createEditor

QWidget *CColumnDelegate::createEditor(QWidget *parent,const QStyleOptionViewItem &option,const QModelIndex &index) const
{
    if (columnindex==ContentIndex)
    {
        QTextEdit* editor = new QTextEdit(parent);
        // disable rich text, we just need multilined QLineEdit functionality :-)
        editor->setAcceptRichText(false);
        return editor;
    }
    else
        if (columnindex==FullIndex)
        {
            // for 'full' column(data type: boolean) we should use SpinBox editor
            QSpinBox* editor = new QSpinBox(parent);
            editor->setRange(0,1);
            return editor;
        }
        else
            return QStyledItemDelegate::createEditor(parent,option,index);
}
开发者ID:Pinkbyte,项目名称:qtdiscs,代码行数:20,代码来源:ccolumndelegate.cpp

示例7: main

int main (int argc, char * argv[])
{
	QStringList lineList;
	QString curLine;
	Dictionary myDict(argv[2]);

  	QApplication myApp(argc, argv);
   	QTextEdit wid;
 	wid.setMinimumSize(500,300);
 	wid.setAcceptRichText(true);
  	QString word;
  	QTextStream stream(&word);
	
	QFile myFile(argv[1]);
	myFile.open(QIODevice::ReadOnly);
	QTextStream inFile(&myFile);

	while(!inFile.atEnd())
	{
		curLine = inFile.readLine();					//file is read
		lineList = curLine.split(QRegExp("\\b"), QString::SkipEmptyParts);	//the string is split into parts
		for (int c = 0; c < lineList.size(); c++)
		{
			if (myDict.dictLook(lineList[c]) == 0)			//if the word was misspelled, then
			{
				stream << "<font color=red>";			//red font tags are placed around the word
				stream << lineList[c];
				stream << "</font>";
			}
			else
			{
				stream << lineList[c];				//otherwise they are just outputted
			}
		}
		wid.append(word);						//printed to text editor
		word = "";							//string cleared
	
	}
 	wid.show();
	return myApp.exec();
}
开发者ID:chunkyboy068,项目名称:archive,代码行数:41,代码来源:main.cpp

示例8: setModel

void SqlItemView::setModel(QAbstractItemModel * model)
{
	m_model = model;
	QSqlQueryModel * t = qobject_cast<QSqlQueryModel *>(model);
	if (!t)  { return; }
	QSqlRecord rec(t->record());

	if (scrollWidget->widget())
	{
		delete scrollWidget->takeWidget();
	}

	QWidget * layoutWidget = new QWidget(scrollWidget);
	m_gridLayout = new QGridLayout(layoutWidget);
	QString tmp("%1:");

	for (int i = 0; i < rec.count(); ++i)
	{
		m_gridLayout->addWidget(
			new QLabel(tmp.arg(rec.fieldName(i)), layoutWidget), i, 0);
		QTextEdit * w = new QTextEdit(layoutWidget);
		w->setReadOnly(false);
		w->setAcceptRichText(false);
		int mh = QFontMetrics(w->currentFont()).lineSpacing();
		w->setMinimumHeight(mh);
		w->setSizePolicy(QSizePolicy::Expanding,
                         QSizePolicy::MinimumExpanding);
		m_gridLayout->addWidget(w, i, 1);
		m_gridLayout->setRowMinimumHeight(i, mh);
		connect(w, SIGNAL(textChanged()),
				this, SLOT(textChanged()));
	}
	scrollWidget->setWidget(layoutWidget);

	m_count = rec.count();
}
开发者ID:ysalmon,项目名称:sqliteman,代码行数:36,代码来源:sqlitemview.cpp

示例9: if


//.........这里部分代码省略.........
      else
      {
        le = new QLineEdit( parent );
      }

      if ( le )
      {
        if ( editType == QgsVectorLayer::UniqueValuesEditable )
        {
          QList<QVariant> values;
          vl->dataProvider()->uniqueValues( idx, values );

          QStringList svalues;
          for ( QList<QVariant>::const_iterator it = values.begin(); it != values.end(); it++ )
            svalues << it->toString();

          QCompleter *c = new QCompleter( svalues );
          c->setCompletionMode( QCompleter::PopupCompletion );
          le->setCompleter( c );
        }

        if ( editType == QgsVectorLayer::UuidGenerator )
        {
          le->setReadOnly( true );
        }

        le->setValidator( new QgsFieldValidator( le, field ) );

        myWidget = le;
      }

      if ( te )
      {
        te->setAcceptRichText( true );
        myWidget = te;
      }

      if ( pte )
      {
        myWidget = pte;
      }

      if ( cb )
      {
        myWidget = cb;
      }

      if ( myWidget )
      {
        myWidget->setDisabled( editType == QgsVectorLayer::Immutable );

        QgsStringRelay* relay = NULL;

        QMap<int, QWidget*>::const_iterator it = proxyWidgets.find( idx );
        if ( it != proxyWidgets.end() )
        {
          QObject* obj = qvariant_cast<QObject*>( (*it)->property( "QgisAttrEditProxy" ) );
          relay = qobject_cast<QgsStringRelay*>( obj );
        }
        else
        {
          relay = new QgsStringRelay( myWidget );
        }

        if ( cb && cb->isEditable() )
        {
开发者ID:hCivil,项目名称:Quantum-GIS,代码行数:67,代码来源:qgsattributeeditor.cpp

示例10: setupUi


//.........这里部分代码省略.........
        checkBoxAutoEnrichParameters->setText(GdbOptionsPage::tr(
            "Use common locations for debug information"));
        checkBoxAutoEnrichParameters->setToolTip(GdbOptionsPage::tr(
            "This adds common paths to locations of debug information\n"
            "at debugger startup."));

        checkBoxBreakOnWarning = new QCheckBox(groupBoxGeneral);
        checkBoxBreakOnWarning->setText(GdbOptionsPage::tr("Stop when a qWarning is issued"));

        checkBoxBreakOnFatal = new QCheckBox(groupBoxGeneral);
        checkBoxBreakOnFatal->setText(GdbOptionsPage::tr("Stop when a qFatal is issued"));

        checkBoxBreakOnAbort = new QCheckBox(groupBoxGeneral);
        checkBoxBreakOnAbort->setText(GdbOptionsPage::tr("Stop when abort() is called"));

        checkBoxEnableReverseDebugging = new QCheckBox(groupBoxGeneral);
        checkBoxEnableReverseDebugging->setText(GdbOptionsPage::tr("Enable reverse debugging"));
        checkBoxEnableReverseDebugging->setToolTip(GdbOptionsPage::tr(
            "<html><head/><body><p>Selecting this enables reverse debugging.</p><.p>"
            "<b>Note:</b> This feature is very slow and unstable on the GDB side."
            "It exhibits unpredictable behavior when going backwards over system "
            "calls and is very likely to destroy your debugging session.</p><body></html>"));

        checkBoxAttemptQuickStart = new QCheckBox(groupBoxGeneral);
        checkBoxAttemptQuickStart->setText(GdbOptionsPage::tr("Attempt quick start"));
        checkBoxAttemptQuickStart->setToolTip(GdbOptionsPage::tr("Checking this option "
            "will postpone reading debug information as long as possible. This can result "
            "in faster startup times at the price of not being able to set breakpoints "
            "by file and number."));

        groupBoxStartupCommands = new QGroupBox(q);
        groupBoxStartupCommands->setTitle(GdbOptionsPage::tr("Additional Startup Commands"));

        textEditStartupCommands = new QTextEdit(groupBoxStartupCommands);
        textEditStartupCommands->setAcceptRichText(false);

        /*
        groupBoxPluginDebugging = new QGroupBox(q);
        groupBoxPluginDebugging->setTitle(GdbOptionsPage::tr(
            "Behavior of Breakpoint Setting in Plugins"));

        radioButtonAllPluginBreakpoints = new QRadioButton(groupBoxPluginDebugging);
        radioButtonAllPluginBreakpoints->setText(GdbOptionsPage::tr(
            "Always try to set breakpoints in plugins automatically"));
        radioButtonAllPluginBreakpoints->setToolTip(GdbOptionsPage::tr(
            "This is the slowest but safest option."));

        radioButtonSelectedPluginBreakpoints = new QRadioButton(groupBoxPluginDebugging);
        radioButtonSelectedPluginBreakpoints->setText(GdbOptionsPage::tr(
            "Try to set breakpoints in selected plugins"));

        radioButtonNoPluginBreakpoints = new QRadioButton(groupBoxPluginDebugging);
        radioButtonNoPluginBreakpoints->setText(GdbOptionsPage::tr(
            "Never set breakpoints in plugins automatically"));

        lineEditSelectedPluginBreakpointsPattern = new QLineEdit(groupBoxPluginDebugging);

        labelSelectedPluginBreakpoints = new QLabel(groupBoxPluginDebugging);
        labelSelectedPluginBreakpoints->setText(GdbOptionsPage::tr(
            "Matching regular expression: "));
        */

        QFormLayout *formLayout = new QFormLayout(groupBoxGeneral);
        formLayout->addRow(labelGdbWatchdogTimeout, spinBoxGdbWatchdogTimeout);
        formLayout->addRow(checkBoxSkipKnownFrames);
        formLayout->addRow(checkBoxUseMessageBoxForSignals);
        formLayout->addRow(checkBoxAdjustBreakpointLocations);
        formLayout->addRow(checkBoxUseDynamicType);
        formLayout->addRow(checkBoxLoadGdbInit);
        formLayout->addRow(checkBoxWarnOnReleaseBuilds);
        formLayout->addRow(new QLabel(QString()));
        formLayout->addRow(labelDangerous);
        formLayout->addRow(checkBoxTargetAsync);
        formLayout->addRow(checkBoxAutoEnrichParameters);
        formLayout->addRow(checkBoxBreakOnWarning);
        formLayout->addRow(checkBoxBreakOnFatal);
        formLayout->addRow(checkBoxBreakOnAbort);
        formLayout->addRow(checkBoxEnableReverseDebugging);
        formLayout->addRow(checkBoxAttemptQuickStart);

        QGridLayout *startLayout = new QGridLayout(groupBoxStartupCommands);
        startLayout->addWidget(textEditStartupCommands, 0, 0, 1, 1);

        //QHBoxLayout *horizontalLayout = new QHBoxLayout();
        //horizontalLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Preferred, QSizePolicy::Minimum));
        //horizontalLayout->addWidget(labelSelectedPluginBreakpoints);
        //horizontalLayout->addWidget(lineEditSelectedPluginBreakpointsPattern);

        QGridLayout *gridLayout = new QGridLayout(q);
        gridLayout->addWidget(groupBoxGeneral, 0, 0);
        gridLayout->addWidget(groupBoxStartupCommands, 0, 1);

        //gridLayout->addWidget(groupBoxStartupCommands, 0, 1, 1, 1);
        //gridLayout->addWidget(radioButtonAllPluginBreakpoints, 0, 0, 1, 1);
        //gridLayout->addWidget(radioButtonSelectedPluginBreakpoints, 1, 0, 1, 1);

        //gridLayout->addLayout(horizontalLayout, 2, 0, 1, 1);
        //gridLayout->addWidget(radioButtonNoPluginBreakpoints, 3, 0, 1, 1);
        //gridLayout->addWidget(groupBoxPluginDebugging, 1, 0, 1, 2);
    }
开发者ID:KDE,项目名称:android-qt-creator,代码行数:101,代码来源:gdboptionspage.cpp

示例11: main

int main(int argc, char *argv[]) {
	QApplication myApp(argc, argv);
	if (argc != 3)
	{
		qDebug() << "Error: invalid usage. \nUsage: <file> <language>";
		return 1;
	}
	// initialize a widget for outputting the results
	QTextEdit myWidget;
	myWidget.setMinimumSize(500,300);
	myWidget.setAcceptRichText(true);

	// File input variables
	QStringList inWords;
	QString text;

	// Map for missed words
	QMap<QString, int> missedList;

	// Input words from file, get rid of punctuation
	QFile inFile(myApp.arguments()[1]);
	if (inFile.open(QIODevice::ReadOnly | QIODevice::Text))
	{
		QTextStream in(&inFile);
		text = in.readAll();
		inWords = text.split(QRegExp("\\W+"), QString::SkipEmptyParts);
	}
	else
	{
		qDebug() << "Error: File could not be found OR doesn't exist!";
		return 1;
	}

	// if language is american use the american-english dictionary
	if (myApp.arguments()[2] == "american")
	{
		QString file = QString("/usr/share/dict/american-english");
		// initialize the dictionary
		Dictionary myAmericanDict(file);
		// create the misspelled word map
		myAmericanDict.isMisspelled(inWords);
		// output the map
		missedList = myAmericanDict.getMissedWords();
	}
	else if (myApp.arguments()[2] == "british")
	{
		QString file = QString("/usr/share/dict/british-english");
		// initialize the dictionary
		Dictionary myBritishDict(file);
		// create the misspelled word map
		myBritishDict.isMisspelled(inWords);
		// output the map
		missedList = myBritishDict.getMissedWords();
	}
	// if language specified is not an option, output error and exit
	else
	{
		qDebug() << "Error: User specified dictionary not found!";
		return 1;
	}
	// variables for formatting misspelled words
	QString sred = "<font color = '#ff0000'>";
	QString ered = "</font>";
	QString temp;

	// go through the missedspelled words and color the word
	// in text red
	foreach(const QString &str, missedList.keys())
	{
		if (text.contains(str))
		{
			temp = sred+str+ered;
			text.replace(str, temp);
		}
	}
	// append and show the formatted text
	myWidget.append(text);
	myWidget.show();
	return myApp.exec();
	//return 0;
}
开发者ID:smparekh,项目名称:Software,代码行数:81,代码来源:main.cpp


注:本文中的QTextEdit::setAcceptRichText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。