本文整理汇总了C++中QPlainTextEdit::setLineWrapMode方法的典型用法代码示例。如果您正苦于以下问题:C++ QPlainTextEdit::setLineWrapMode方法的具体用法?C++ QPlainTextEdit::setLineWrapMode怎么用?C++ QPlainTextEdit::setLineWrapMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPlainTextEdit
的用法示例。
在下文中一共展示了QPlainTextEdit::setLineWrapMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: catchException
void catchException(const std::exception& ex) {
QString error = QString::fromUtf8(ex.what());
QString message = "<qt><b>qtfuzzylite</b> has experienced an internal error and will exit.<br><br>"
"Please report this error to <a href='mailto:[email protected]'>"
"[email protected]</a><br><br>"
"Your report will help to make <b>fuzzylite</b> and <b>qtfuzzylite</b> a better "
"free open source fuzzy logic library!<br><br>"
"Many thanks in advance for your help!"
"</qt>";
QMessageBox x(NULL);
x.setText(message);
x.setWindowTitle("Internal Error");
x.setIcon(QMessageBox::Critical);
QLabel dummy;
x.layout()->addWidget(&dummy);
QLabel viewLabel("Error message:");
QPlainTextEdit viewError;
viewError.setReadOnly(true);
viewError.setPlainText(error);
viewError.setLineWrapMode(QPlainTextEdit::NoWrap);
QFont tt("?");
tt.setStyleHint(QFont::TypeWriter);
tt.setPointSize(tt.pointSize() - 2);
viewError.setFont(tt);
QWidget* view = new QWidget;
view->setLayout(new QVBoxLayout);
view->layout()->addWidget(&viewLabel);
view->layout()->addWidget(&viewError);
x.layout()->addWidget(view);
x.exec();
}
示例2: readme
About::About(QWidget * parent, Qt::WindowFlags f)
: QDialog(parent, f)
{
// stuff
setWindowTitle("About LibreLibreCell");
QLabel *versionLabel = new QLabel(QString("Git revision: %1").arg(LIBRELIBRECELL_VERSION));
QPlainTextEdit *aboutBox = new QPlainTextEdit;
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
QVBoxLayout *vLayout = new QVBoxLayout;
vLayout->addWidget(versionLabel);
vLayout->addWidget(aboutBox, 1);
vLayout->addSpacing(10);
vLayout->addWidget(buttonBox);
setLayout(vLayout);
aboutBox->setReadOnly(true);
aboutBox->setTabChangesFocus(true);
aboutBox->setWordWrapMode(QTextOption::NoWrap);
aboutBox->setLineWrapMode(QPlainTextEdit::NoWrap);
aboutBox->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
aboutBox->setFont(QFont("Monospace", 10));
QFile readme(":/README.txt");
if (readme.open(QIODevice::ReadOnly))
{
QTextStream stream(&readme);
aboutBox->setPlainText(stream.readAll());
readme.close();
}
else
{
aboutBox->setPlainText("Could not open README.txt.");
}
QFontMetrics fm(aboutBox->font());
aboutBox->setMinimumSize(fm.width(QLatin1Char('m')) * 76, 450);
connect(buttonBox, SIGNAL(accepted()),
this, SLOT(accept()));
}
示例3: createValueWidget
void SettingWidget::createValueWidget()
{
rsArgument* argument = task->getArgument(option->name);
switch(option->type) {
case G_OPTION_ARG_FILENAME:
case G_OPTION_ARG_STRING:
case G_OPTION_ARG_STRING_ARRAY:
case G_OPTION_ARG_CALLBACK:
case G_OPTION_ARG_INT:
case G_OPTION_ARG_INT64:
case G_OPTION_ARG_DOUBLE:
{
// Display text box if number of values is not restricted
if ( option->allowedValues == NULL ) {
if ( option->nLines < 2 ) {
QLineEdit *w = new QLineEdit();
valueWidget = w;
w->setPlaceholderText(option->cli_arg_description);
connect(w, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
if ( argument != NULL ) {
w->setText(argument->value);
} else if ( option->defaultValue != NULL ) {
w->setText(option->defaultValue);
}
} else { // create a QTextEdit field instead
QPlainTextEdit *w = new QPlainTextEdit();
valueWidget = w;
connect(w, SIGNAL(textChanged()), this, SLOT(textChanged()));
if ( argument != NULL ) {
w->setPlainText(argument->value);
} else if ( option->defaultValue != NULL ) {
w->setPlainText(option->defaultValue);
}
QFontMetrics m(w->font()) ;
int rowHeight = m.lineSpacing() ;
w->setFixedHeight(option->nLines * rowHeight) ;
w->setLineWrapMode(QPlainTextEdit::NoWrap);
}
} else { // if the allowed values are restricted display radio buttons instead
QWidget *w = new QWidget();
QBoxLayout *wLayout = new QBoxLayout(QBoxLayout::TopToBottom);
QButtonGroup *buttonGroup = new QButtonGroup();
buttonGroup->setExclusive(true);
valueWidget = w;
connect(buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(buttonClicked(int)));
// go through all options and add a radio button for them
rsUIOptionValue** values = option->allowedValues;
for (size_t i=0; values[i] != NULL; i++ ) {
// add radio button
QRadioButton *b = new QRadioButton(QString("'")+QString(values[i]->name)+QString("'"));
QFont f("Arial", 12, QFont::Bold);
b->setFont(f);
buttonGroup->addButton(b, (int)i);
wLayout->addWidget(b);
// set it to checked if it is the default or set value
b->setChecked(false);
if ( argument != NULL ) {
if ( ! strcmp(argument->value,values[i]->name) ) {
b->setChecked(true);
}
} else if ( ! strcmp(option->defaultValue,values[i]->name) ) {
b->setChecked(true);
}
// add its description
QLabel *label = new QLabel(values[i]->description);
label->setIndent(22);
label->setWordWrap(true);
label->setContentsMargins(0, 0, 0, 4);
QFont f2("Arial", 11, QFont::Normal);
label->setFont(f2);
wLayout->addWidget(label);
}
w->setLayout(wLayout);
}
}
break;
/*
case G_OPTION_ARG_INT:
case G_OPTION_ARG_INT64:
valueWidget = new QSpinBox();
break;
case G_OPTION_ARG_DOUBLE:
valueWidget = new QDoubleSpinBox();
break;
*/
case G_OPTION_ARG_NONE:
{
QCheckBox *w = new QCheckBox("Enabled"); // new SwitchWidget();
valueWidget = w;
connect(w, SIGNAL(stateChanged(int)), this, SLOT(stateChanged(int)));
if ( argument != NULL ) {
w->setCheckState(Qt::Checked);
} else {
w->setCheckState(Qt::Unchecked);
}
}
//.........这里部分代码省略.........