bool ResizableMessageBox::event(QEvent *e) { bool result = QMessageBox::event(e); //QMessageBox::event in this case will call setFixedSize on the dialog frame, making it not resizable by the user if ( (e->type() == QEvent::LayoutRequest) || (e->type() == QEvent::Resize) ) { setMinimumHeight(0); setMaximumHeight(QWIDGETSIZE_MAX); setMinimumWidth(0); setMaximumWidth(QWIDGETSIZE_MAX); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // make the detailed text expanding QTextEdit *textEdit = findChild<QTextEdit *>(); if (textEdit) { textEdit->setMinimumHeight(0); textEdit->setMaximumHeight(QWIDGETSIZE_MAX); textEdit->setMinimumWidth(0); textEdit->setMaximumWidth(QWIDGETSIZE_MAX); textEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); } } return result; }
ScrollBarSettingsEditor::ScrollBarSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::ScrollBarSettingsForm), m_verticalScrollbar(new QtMaterialScrollBar), m_horizontalScrollbar(new QtMaterialScrollBar) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); QWidget *widget = new QWidget; layout->addWidget(widget); QWidget *canvas = new QWidget; canvas->setStyleSheet("QWidget { background: white; }"); layout->addWidget(canvas); ui->setupUi(widget); layout->setContentsMargins(20, 20, 20, 20); layout = new QVBoxLayout; canvas->setLayout(layout); canvas->setMaximumHeight(400); QTextEdit *edit = new QTextEdit; edit->setText("<p>The distinction between the subjects of syntax and semantics has its origin in the study of natural languages.</p><p>The distinction between the subjects of syntax and semantics has its origin in the study of natural languages.</p><p>The distinction between the subjects of syntax and semantics has its origin in the study of natural languages.</p><p>The distinction between the subjects of syntax and semantics has its origin in the study of natural languages.</p><p>The distinction between the subjects of syntax and semantics has its origin in the study of natural languages.</p><p>The distinction between the subjects of syntax and semantics has its origin in the study of natural languages.</p><p>The distinction between the subjects of syntax and semantics has its origin in the study of natural languages.</p><p>The distinction between the subjects of syntax and semantics has its origin in the study of natural languages.</p>"); edit->setLineWrapMode(QTextEdit::NoWrap); edit->update(); edit->setMaximumHeight(200); edit->setVerticalScrollBar(m_verticalScrollbar); edit->setHorizontalScrollBar(m_horizontalScrollbar); //m_verticalScrollbar->setHideOnMouseOut(false); //m_horizontalScrollbar->setHideOnMouseOut(false); m_horizontalScrollbar->setOrientation(Qt::Horizontal); layout->addWidget(edit); layout->setAlignment(edit, Qt::AlignHCenter); setupForm(); }
//---------------------------------------------------------------------------- void DynamicEditor::setupTabs(QDomDocument *elmerDefs, const QString &Section, int ID) { // Clear: //------- this->ID = ID; hash.clear(); QLayout *layout = this->layout(); if(layout != NULL) { QLayoutItem *item; while((item = layout->takeAt(0)) != 0) delete item; if(tabWidget != NULL) { tabWidget->clear(); delete tabWidget; } delete layout; } // Get root element of elmerDefs: //------------------------------- root = elmerDefs->documentElement(); tabWidget = new QTabWidget; //tabWidget->setTabShape(QTabWidget::Triangular); tabWidget->setUsesScrollButtons(true); tabWidget->setElideMode(Qt::ElideNone); all_stuff = root.firstChildElement("ALL"); element = root.firstChildElement("PDE"); tabs = 0; while(!element.isNull()) { name = element.firstChildElement("Name"); QGridLayout *grid = new QGridLayout; int params = 0; for( int iter=0; iter<2; iter++ ) { if ( iter==0 ) { if ( name.text().trimmed() == "General" ) continue; section = all_stuff.firstChildElement(Section); } else { section = element.firstChildElement(Section); } param = section.firstChildElement("Parameter"); // ML: Added argument "Parameter" for nextSiblingElement(), 5. August 2010: for( ; !param.isNull(); param=param.nextSiblingElement("Parameter"), params++ ) { // label QString widget_type = param.attribute("Widget","Edit"); QString widget_enabled = param.attribute("Enabled","True"); QString widget_visible = param.attribute("Visible","True"); QString paramType = param.firstChildElement("Type").text().trimmed(); QString labelName = param.firstChildElement("Name").text().trimmed(); QString sifName = param.firstChildElement("SifName").text().trimmed(); if ( sifName == "" ) sifName = labelName; QString paramDefault = param.firstChildElement("DefaultValue").text().trimmed(); QString whatis = param.firstChildElement("Whatis").text().trimmed(); QString statusTip = param.firstChildElement("StatusTip").text().trimmed(); QString fullName = "/"+name.text().trimmed()+"/"+Section+"/"+labelName+"/"+QString::number(ID); h.widget = NULL; if ( widget_type == "Edit" ) { DynLineEdit *edit = new DynLineEdit; h.widget = edit->lineEdit; edit->lineEdit->setText(paramDefault); edit->name = fullName; connect(edit->lineEdit, SIGNAL(returnPressed()), edit, SLOT(editSlot())); connect(edit->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(textChangedSlot(QString))); } else if (widget_type == "TextEdit") { QTextEdit *textEdit = new QTextEdit; // set height to 5..8 lines of current font: QFont currentFont = textEdit->currentFont(); QFontMetrics fontMetrics(currentFont); int fontHeight = fontMetrics.height(); textEdit->setMinimumHeight(5*fontHeight); textEdit->setMaximumHeight(8*fontHeight); h.widget = textEdit; } else if ( widget_type == "Combo" ) { QComboBox *combo = new QComboBox; h.widget = combo; // combo->setObjectName(labelName); // removed 30. sept. 2008, ML int count = 0, active=0; QDomElement item = param.firstChildElement("Item"); for( ; !item.isNull(); item=item.nextSiblingElement("Item") ) { QString itemType = item.attribute( "Type", "" ); if ( itemType == "Active" ) active=count; QDomElement itemName = item.firstChildElement("Name"); combo->insertItem(count++,itemName.text().trimmed() ); } combo->setCurrentIndex(active); // connect(combo, SIGNAL(activated(QString)), this, SLOT(comboSlot(QString))); connect(combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(comboSlot(QString))); } else if ( widget_type == "CheckBox" ) { QCheckBox *l = new QCheckBox; h.widget = l; l->setText(""); l->setChecked(false); if ( paramDefault == "True" ) l->setChecked(true); connect(l, SIGNAL(stateChanged(int)), this, SLOT(lSlot(int))); } else if ( widget_type == "Label" ) { QLabel *label = new QLabel; QFont font; font.setBold(true); font.setUnderline(true); label->setFont(font); label->setText(labelName); h.widget = label; } if ( h.widget ) { h.widget->setWhatsThis(whatis); h.widget->setStatusTip(statusTip); h.widget->setProperty( "dom address",fullName); h.elem = param; if ( widget_enabled == "False" ) h.widget->setEnabled(false); if(widget_type != "TextEdit") h.widget->setFixedHeight(18); if(widget_type == "TextEdit") { QLabel *textEditLabel = new QLabel; textEditLabel->setText(labelName); h.label = textEditLabel; grid->addWidget(h.widget, params, 0, 1, 2); if ( widget_visible == "False" ) { h.label->hide(); h.widget->hide(); } } else if ( widget_type != "Label" ) { QLabel *label = new QLabel; label->setText(labelName); h.label = label; grid->addWidget(h.label, params, 0); grid->addWidget(h.widget, params, 1); if ( widget_visible == "False" ) { h.label->hide(); h.widget->hide(); } } else { h.label = NULL; grid->addWidget(h.widget, params, 0); } hash[fullName] = h; } } }
void PlotDataFitFunctionWidget::initialize() { QProcessorWidget::initialize(); QGridLayout* mainLayout = new QGridLayout(this); QLabel* label = new QLabel(this); label->setText(QString(tr("Fitting Function",0))); label->setAlignment(Qt::AlignHCenter); QFont font = label->font(); font.setBold(true); font.setPointSize(14); label->setFont(font); mainLayout->addWidget(label,0,0,1,3); widgetVector_.push_back(label); label = new QLabel(this); label->setText(QString(tr("Function:",0))); label->setFixedWidth(100); mainLayout->addWidget(label,1,0,1,1); widgetVector_.push_back(label); QTextEdit* textedit = new QTextEdit(QString(tr("No FitFunction Selected",0)),this); textedit->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); textedit->setReadOnly(true); textedit->setMaximumHeight(200); textedit->setMinimumHeight(20); mainLayout->addWidget(textedit,1,1,1,2); widgetVector_.push_back(textedit); label = new QLabel(this); label->setText(QString(tr("Fittingcolumn:",0))); label->setFixedWidth(100); mainLayout->addWidget(label,2,0,1,1); widgetVector_.push_back(label); label = new QLabel(this); label->setText(QString(tr("Column-Value",0))); mainLayout->addWidget(label,2,1,1,1); widgetVector_.push_back(label); label = new QLabel(this); label->setText(QString(tr("MSE:",0))); label->setFixedWidth(100); mainLayout->addWidget(label,3,0,1,1); widgetVector_.push_back(label); label = new QLabel(this); label->setText(QString(tr("MSE-Value",0))); mainLayout->addWidget(label,3,1,1,1); widgetVector_.push_back(label); delete proxyModel_; proxyModel_ = new PlotDataExtendedTableModel(NULL, std::vector<std::pair<int,std::string> >(0), this); table_ = new ExtendedTable(this); table_->setModel(proxyModel_); table_->setSortingEnabled(false); table_->verticalHeader()->hide(); table_->resizeColumnsToContents(); table_->setMinimumHeight(150); mainLayout->addWidget(table_, 4, 0, 1, 3); table_->setContextMenuPolicy(Qt::CustomContextMenu); table_->horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu); QObject::connect(table_,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(tableContextMenu(const QPoint&))); QObject::connect(table_->horizontalHeader(),SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(tableContextMenu(const QPoint&))); setLayout(mainLayout); for (size_t i = 1; i < widgetVector_.size(); ++i) { widgetVector_[i]->setVisible(false); } //show(); initialized_ = true; }