本文整理汇总了C++中QPlainTextEdit::setFixedHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ QPlainTextEdit::setFixedHeight方法的具体用法?C++ QPlainTextEdit::setFixedHeight怎么用?C++ QPlainTextEdit::setFixedHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPlainTextEdit
的用法示例。
在下文中一共展示了QPlainTextEdit::setFixedHeight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
//.........这里部分代码省略.........