int main(int argc, char *argv[]) { QApplication a(argc, argv); shareFrameData threadShareData(640, 480); NetWorkHandle netWorkThread; MainWindow w; QWidget mainWidget(&w); QHBoxLayout mainLayout; QVBoxLayout leftLayout; QVBoxLayout rightLayout; QHBoxLayout controlLayout; QVBoxLayout statuLayout; MyVideoView videoView(&w); MyButton flyControl(&w); MyButton otherSet(&w); MyButton balanceStatu(&w); MyButton paramStatu(&w); w.setMinimumSize(QSize(800, 480)); flyControl.setText(QString("flycontrol")); otherSet.setText(QString("otherset")); balanceStatu.setText(QString("balance param")); paramStatu.setText(QString("net & other statu")); //w.setCentralWidget(&button); leftLayout.addWidget(&videoView); leftLayout.setStretch(0, 7); controlLayout.addWidget(&flyControl); controlLayout.addWidget(&otherSet); leftLayout.addLayout(&controlLayout); leftLayout.setStretch(1, 3); mainLayout.addLayout(&leftLayout); mainLayout.setStretch(0, 7); rightLayout.addWidget(&balanceStatu); rightLayout.addWidget(¶mStatu); //mainLayout.setStretchFactor(&leftLayout, 5); //mainLayout.setStretchFactor(&rightLayout, 15); mainLayout.addLayout(&rightLayout); mainLayout.setStretch(1, 3); mainWidget.setLayout(&mainLayout); w.setCentralWidget(&mainWidget); QObject::connect(&netWorkThread, SIGNAL(recvData()), &videoView, SLOT(flushScreen())); netWorkThread.setShareBuff(&threadShareData); videoView.setShareBuff(&threadShareData); //start net work thread netWorkThread.start(); w.show(); return a.exec(); }
QGroupBox* ScreenSetting::CreateBoxSystemSettings() { /*新窗口*/ m_groupboxSystemSettings = new QGroupBox; /*布局*/ QVBoxLayout* layoutSystemSettings = new QVBoxLayout(m_groupboxSystemSettings); QHBoxLayout* layoutLanguage = new QHBoxLayout; QHBoxLayout* layoutDate = new QHBoxLayout; QHBoxLayout* layoutTime = new QHBoxLayout; layoutSystemSettings->addStretch(0); layoutSystemSettings->addLayout(layoutLanguage); layoutSystemSettings->addStretch(0); layoutSystemSettings->addLayout(layoutDate); layoutSystemSettings->addStretch(0); layoutSystemSettings->addLayout(layoutTime); layoutSystemSettings->addStretch(0); /*创建窗口控件并布局*/ m_lbLanguage = new QLabel; m_lbDate = new QLabel; m_lbTime = new QLabel; m_cmbLanguage = new QComboBox; m_ltDateValue = new QLineEdit; m_ltTimeValue = new QLineEdit; layoutLanguage->addWidget(m_lbLanguage); layoutLanguage->addWidget(m_cmbLanguage); layoutLanguage->setStretch(0, 1); layoutLanguage->setStretch(1, 1); layoutDate->addWidget(m_lbDate); layoutDate->addWidget(m_ltDateValue); layoutDate->setStretch(0, 1); layoutDate->setStretch(1, 1); layoutTime->addWidget(m_lbTime); layoutTime->addWidget(m_ltTimeValue); layoutTime->setStretch(0, 1); layoutTime->setStretch(1, 1); /*为控件添加内容*/ for (auto var :Language::LANGUAGES) { m_cmbLanguage->addItem(var.first, var.second); } connect(m_cmbLanguage, SIGNAL(currentIndexChanged(int)), this, SLOT(SlotChangeLanguage(int))); /*设置控件样式*/ //m_ltDateValue->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); //m_ltTimeValue->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); m_ltDateValue->setEnabled(false); m_ltTimeValue->setEnabled(false); return m_groupboxSystemSettings; }
IpWidget::IpWidget(QWidget *parent) : QFrame(parent) { setFrameShape( QFrame::StyledPanel ); setFrameShadow( QFrame::Sunken ); QHBoxLayout* pLayout = new QHBoxLayout( this ); setLayout( pLayout ); pLayout->setContentsMargins( 0, 0, 0, 0 ); pLayout->setSpacing( 0 ); for ( int i = 0; i != QTUTL_IP_SIZE; ++i ) { if ( i != 0 ) { QLabel* pDot = new QLabel( ".", this ); pDot->setStyleSheet( "background: white" ); pLayout->addWidget( pDot ); pLayout->setStretch( pLayout->count(), 0 ); } lineEdits[i] = new QLineEdit( this ); QLineEdit* pEdit = lineEdits[i]; pEdit->installEventFilter( this ); pLayout->addWidget( pEdit ); pLayout->setStretch( pLayout->count(), 1 ); pEdit->setFrame( false ); pEdit->setAlignment( Qt::AlignCenter ); QFont font = pEdit->font(); font.setStyleHint( QFont::Monospace ); font.setFixedPitch( true ); pEdit->setFont( font ); QRegExp rx ( "^(0|[1-9]|[1-9][0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))$" ); QValidator *validator = new QRegExpValidator(rx, pEdit); pEdit->setValidator( validator ); } lineEdits[0]->setText("127"); lineEdits[1]->setText("0"); lineEdits[2]->setText("0"); lineEdits[3]->setText("1"); setMaximumWidth( 30 * QTUTL_IP_SIZE ); connect( this, SIGNAL(signalTextChanged(QLineEdit*)), this, SLOT(slotTextChanged(QLineEdit*)), Qt::QueuedConnection ); }
QGroupBox* ScreenSetting::CreateBoxRobotControlAuthority() { /*创建窗口*/ m_groupboxRobotControlAuthority = new QGroupBox; /*布局*/ QVBoxLayout* layoutRobotControlAuthority = new QVBoxLayout(m_groupboxRobotControlAuthority); QHBoxLayout* layoutControlAuthority = new QHBoxLayout; QHBoxLayout* layoutDevice = new QHBoxLayout; QHBoxLayout* layoutDeviceIp = new QHBoxLayout; layoutRobotControlAuthority->addStretch(0); layoutRobotControlAuthority->addLayout(layoutControlAuthority); layoutRobotControlAuthority->addStretch(0); layoutRobotControlAuthority->addLayout(layoutDevice); layoutRobotControlAuthority->addStretch(0); layoutRobotControlAuthority->addLayout(layoutDeviceIp); layoutRobotControlAuthority->addStretch(0); /*创建窗口控件并布局*/ m_lbControlAuthority = new QLabel; m_checkboxControlAuthority = new QCheckBox; m_checkboxControlAuthority->setChecked(false); m_lbDevice = new QLabel; m_ltDeviceValue = new QLineEdit; m_lbDeviceIp = new QLabel; m_ltDeviceIpValue = new QLineEdit; layoutControlAuthority->addWidget(m_lbControlAuthority); layoutControlAuthority->addWidget(m_checkboxControlAuthority); layoutControlAuthority->setStretch(0, 1); layoutControlAuthority->setStretch(1, 1); layoutControlAuthority->setAlignment(m_checkboxControlAuthority, Qt::AlignRight); layoutDevice->addWidget(m_lbDevice); layoutDevice->addWidget(m_ltDeviceValue); layoutDevice->setStretch(0, 1); layoutDevice->setStretch(1, 1); layoutDeviceIp->addWidget(m_lbDeviceIp); layoutDeviceIp->addWidget(m_ltDeviceIpValue); layoutDeviceIp->setStretch(0, 1); layoutDeviceIp->setStretch(1, 1); /*设置控件样式*/ //m_ltDeviceValue->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); //m_ltDeviceIpValue->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); m_ltDeviceValue->setEnabled(false); m_ltDeviceIpValue->setEnabled(false); return m_groupboxRobotControlAuthority; }
EDFViewerWindow::EDFViewerWindow(QWidget *parent) : QWidget(parent){ QVBoxLayout *vb; QHBoxLayout *hb; QMenu *menu; QAction *act; QMenuBar* menuBar; vb=new QVBoxLayout(); hb=new QHBoxLayout(); vb->addLayout(hb); menuBar = new QMenuBar(); menu= menuBar->addMenu(tr("&File")); act=new QAction(tr("&Open"), this); menu->addAction(act); connect(act, SIGNAL(triggered()), this, SLOT(fileOpen())); act=new QAction(tr("&Exit"), this); connect(act, SIGNAL(triggered()), this, SLOT(close())); menu->addAction(act); menu= menuBar->addMenu(tr("&EDF")); act=new QAction(tr("&EDF Data"), this); menu->addAction(act); QObject::connect(act,&QAction::triggered,datawindow); act=new QAction(tr("&Signals"), this); menu->addAction(act); QObject::connect(act,&QAction::triggered,signalswindow); hb->addWidget(menuBar); hb->setStretch(hb->count()-1,1); menuBar = new QMenuBar(); menu= menuBar->addMenu(tr("&Help")); act=new QAction(tr("&About"), this); menu->addAction(act); QObject::connect(act,&QAction::triggered,aboutwindow); hb->addWidget(menuBar); vb->addWidget(paintWidget=new PaintWidget()); vb->setStretch(vb->count()-1,1); hScrollBar = new QScrollBar(Qt::Horizontal, this); connect(hScrollBar, SIGNAL(valueChanged(int)),this,SLOT(changehbar(int))); hb=new QHBoxLayout(); hb->addWidget(hScrollBar); hb->setStretch(hb->count()-1,1); le1=new QLineEdit(); le1->setText("4"); le1->setFixedSize(32,16); hb->addWidget(le1); connect(le1, SIGNAL(textChanged(const QString &)), this, SLOT(screentimechanged(const QString &))); hb->addWidget(new QLabel("sec")); vb->addLayout(hb); resize(450,400); setLayout(vb); }
void DWindowUI::InitUI() { QHBoxLayout *top = new QHBoxLayout(); AddProcessUI(top); top->setStretch(0, 230); AddOptionUI(top); top->setStretch(1, 430); QWidget *window = new QWidget(this); window->setLayout(top); setCentralWidget(window); usbTimer_ = new QTimer(this); usbTimer_->setInterval(3000); connect(usbTimer_, SIGNAL(timeout()), this, SLOT(refrshUsbDriverList())); usbTimer_->start(); }
QLayout * PageScheme::footerLayoutDefinition() { QHBoxLayout * bottomLayout = new QHBoxLayout(); selectScheme = new QComboBox(this); bottomLayout->addWidget(selectScheme, 0); BtnCopy = addButton(tr("Copy"), bottomLayout, 1); BtnNew = addButton(tr("New"), bottomLayout, 2); BtnDelete = addButton(tr("Delete"), bottomLayout, 3); bottomLayout->setStretch(1,1); bottomLayout->setStretch(2,1); bottomLayout->setStretch(3,1); return bottomLayout; }
void ChatDialog::initLayout() { QVBoxLayout *infoLayout = new QVBoxLayout; infoLayout->addWidget(peerName); infoLayout->addWidget(peerAddress); /**************************************** QHBoxLayout *peerLayout = new QHBoxLayout; peerLayout->addWidget(iconLabel); peerLayout->addLayout(infoLayout); peerLayout->setStretch(0, 1); peerLayout->setStretch(1, 6); ****************************************/ QHBoxLayout *sendLayout = new QHBoxLayout; sendLayout->addWidget(msgSend); sendLayout->addWidget(sendButton); sendLayout->setStretch(0, 5); sendLayout->setStretch(1, 1); QVBoxLayout *dialogLayout = new QVBoxLayout; //dialogLayout->addLayout(peerLayout); dialogLayout->addLayout(infoLayout); dialogLayout->addWidget(logChat); dialogLayout->addLayout(sendLayout); dialogLayout->setStretch(0, 1); dialogLayout->setStretch(1, 8); dialogLayout->setStretch(2, 2); this->setLayout(dialogLayout); }
QDoubleEditSlider::QDoubleEditSlider(const QString & name, QWidget *parent) : QWidget(parent) { m_label = new QLabel(name); m_label->setMinimumWidth(100); m_edit = new QLineEdit; m_edit->setMaximumWidth(80); m_slider = new QSlider(Qt::Horizontal); m_validate = new QDoubleValidator(this); m_edit->setValidator(m_validate); m_slider->setRange(0, 100); QHBoxLayout * layout = new QHBoxLayout; layout->addWidget(m_label); layout->addWidget(m_edit); layout->addWidget(m_slider); layout->setStretch(2, 1); layout->setContentsMargins(0, 0, 0, 0); setLayout(layout); setLimit(0.1, 10.0); setValue(5.0); connect(m_edit, SIGNAL(returnPressed()), this, SLOT(validateEditValue())); connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(convertEditValue(int))); }
QWidget *StartWidget::createMainWidget() { QWidget * const result = new QWidget; result->setStyleSheet(BrandManager::styles()->startTabBackgroundStyle()); QWidget * const header = createHeader(); mRecentProjectsWidget = createRecentProjectsWidget(); QWidget * const projectsManagement = createProjectsManagementWidget(); QVBoxLayout * mainLayout = new QVBoxLayout; QHBoxLayout * contentsLayout = new QHBoxLayout; mainLayout->addWidget(header); mainLayout->addLayout(contentsLayout); mainLayout->setStretch(1, 10); if (mRecentProjectsWidget) { contentsLayout->addWidget(mRecentProjectsWidget); } contentsLayout->addWidget(projectsManagement); contentsLayout->setStretch(0, 10); contentsLayout->setStretch(1, 20); result->setLayout(mainLayout); result->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); return result; }
void tst_QBoxLayout::testLayoutEngine() { QFETCH(DescrList, itemDescriptions); QFETCH(int, size); QFETCH(int, spacing); QFETCH(PosList, expectedPositions); QFETCH(SizeList, expectedSizes); QHBoxLayout box; box.setSpacing(spacing); int i; for (i = 0; i < itemDescriptions.count(); ++i) { Descr descr = itemDescriptions.at(i); LayoutItem *li = new LayoutItem(descr); box.addItem(li); box.setStretch(i, descr.stretch); } box.setGeometry(QRect(0,0,size,100)); for (i = 0; i < expectedSizes.count(); ++i) { int xSize = expectedSizes.at(i); int xPos = expectedPositions.at(i); QLayoutItem *item = box.itemAt(i); QCOMPARE(item->geometry().width(), xSize); QCOMPARE(item->geometry().x(), xPos); } }
QWidget* createWidget( QWidget* parent, ConfigurableItem* item ) { QString tooltip = item->help(); QWidget* widget = new QWidget(parent); widget->setToolTip( tooltip ); QHBoxLayout* layout = new QHBoxLayout( widget ); layout->setContentsMargins( 0, 0, 0, 0 ); ConfigurationWidget* configWidget = ConfigurationWidget::create( item, widget ); QPushButton* defaultButton = new QPushButton( widget ); defaultButton->setMaximumSize( 20, 20 ); defaultButton->setIcon( QIcon(":/oldIcons/oldIcons/1411737168_POWER - RESTART.png") ); defaultButton->setToolTip( ConfigurationDialog::tr("Reset value to default.") ); QObject::connect( defaultButton, &QPushButton::clicked, [item, configWidget, defaultButton]() { item->restore(); configWidget->updateEdit(); defaultButton->setEnabled( false ); }); QObject::connect( configWidget, &ConfigurationWidget::valueChanged, [defaultButton, item](QVariant value) { defaultButton->setEnabled( value != item->defaultValue() ); }); defaultButton->setEnabled( item->actualValue() != item->defaultValue() ); layout->addWidget( configWidget ); layout->addWidget( defaultButton ); layout->setStretch(1, 0); widget->setLayout( layout ); return widget; }
CWizSearchWidget::CWizSearchWidget(QWidget* parent /* = 0 */) : QWidget(parent) , m_widthHint(360) { QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); setSizePolicy(sizePolicy); setContentsMargins(1, 0, 1, 1); m_editSearch = new CWizSearchEdit(this); m_editSearch->setTextMargins(20, 1, 0, 1); m_editSearch->setStyleSheet("QLineEdit{background-color:#eeeeee;border:1px solid #aeaeae; border-radius:10px;}" "QLineEdit::focus{background-color:#ffffff;border:1px solid #6699cb; border-radius:10px;}"); // avoid focus rect on OSX, this should be a bug of qt style sheet m_editSearch->setAttribute(Qt::WA_MacShowFocusRect, 0); QHBoxLayout* layout = new QHBoxLayout(this); setLayout(layout); layout->setSpacing(0); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(m_editSearch); layout->setStretch(1, 1); connect(m_editSearch, SIGNAL(returnPressed()), \ SLOT(on_search_returnPressed())); connect(m_editSearch, SIGNAL(textChanged(QString)), \ SLOT(on_searchTextChanged(QString)), Qt::QueuedConnection); }
QWidget * MTContactDetails::createSingleAddressWidget(int nContactID, QString qstrType, QString qstrTypeDisplay, QString qstrAddress) { QWidget * pWidget = new QWidget; QLineEdit * pType = new QLineEdit(qstrTypeDisplay); QLabel * pLabel = new QLabel(tr("Address:")); // QLineEdit * pAddress = new QLineEdit(qstrDisplayAddr); QLineEdit * pAddress = new QLineEdit(qstrAddress); QPushButton * pBtnDelete = new QPushButton(tr("Delete")); // ---------------------------------------------------------- pType ->setMinimumWidth(60); pLabel ->setMinimumWidth(55); pLabel ->setMaximumWidth(55); pAddress->setMinimumWidth(60); pType ->setReadOnly(true); pAddress->setReadOnly(true); pType ->setStyleSheet("QLineEdit { background-color: lightgray }"); pAddress->setStyleSheet("QLineEdit { background-color: lightgray }"); pBtnDelete->setProperty("contactid", nContactID); pBtnDelete->setProperty("methodtype", qstrType); pBtnDelete->setProperty("methodaddr", qstrAddress); pBtnDelete->setProperty("methodwidget", VPtr<QWidget>::asQVariant(pWidget)); // ---------------------------------------------------------- QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(pType); layout->addWidget(pLabel); layout->addWidget(pAddress); layout->addWidget(pBtnDelete); // ---------------------------------------------------------- pWidget->setLayout(layout); connect(pBtnDelete, SIGNAL(clicked()), this, SLOT(on_btnAddressDelete_clicked())); // ---------------------------------------------------------- layout->setStretch(0, 0); layout->setStretch(1, -1); layout->setStretch(2, 0); layout->setStretch(3, 1); // ---------------------------------------------------------- pType ->home(false); pAddress->home(false); // ---------------------------------------------------------- return pWidget; }
void PlayerControls::setupTrackbar() { QHBoxLayout *hLayout = new QHBoxLayout(); QHBoxLayout *hLayoutTop = new QHBoxLayout(); QHBoxLayout *hLayoutActions = new QHBoxLayout(); QVBoxLayout *vLayout = new QVBoxLayout(); Settings *sett = Settings::instance(); m_wlTitle = new QLabel(sett->getValue("song/title").toString()); m_wlTitle->setStyleSheet("font-size: 17pt;"); m_wlTitle->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); m_wlTitle->setAlignment(Qt::AlignLeft|Qt::AlignBottom); m_wlArtist = new QLabel(sett->getValue("song/artist").toString()); m_wlArtist->setStyleSheet("font-size: 11pt;"); m_wlAlbum = new QLabel(sett->getValue("song/album").toString()); m_wlAlbum->setStyleSheet("font-size: 10pt; color: grey;"); m_wlAlbum->setAlignment(Qt::AlignLeft|Qt::AlignVCenter); // Track actions m_wbDownload = new StyledButton(QIcon(QPixmap(":icons/panel_download")), ""); m_wbDownload->setTransparent(true); m_wbDownload->setToolTip(tr("Download track")); connect(m_wbDownload, SIGNAL(clicked()), SLOT(downloadTrack())); m_wbAdd2List = new StyledButton(QIcon(QPixmap(":icons/panel_listadd")), ""); m_wbAdd2List->setTransparent(true); m_wbAdd2List->setToolTip(tr("Add to list")); m_wbAdd2List->setMenu(m_localsMenu); m_wbAdd2Library = new StyledButton(QIcon(QPixmap(":icons/panel_libraryadd")), ""); m_wbAdd2Library->setTransparent(true); m_wbAdd2Library->setToolTip(tr("Add to library")); connect(m_wbAdd2Library, SIGNAL(clicked()), SLOT(addTrack2Library())); hLayoutTop->addWidget(m_wlTitle); hLayoutTop->addLayout(hLayoutActions); hLayoutTop->setAlignment(hLayoutActions, Qt::AlignRight); hLayoutActions->addWidget(m_wbAdd2Library); hLayoutActions->addWidget(m_wbAdd2List); hLayoutActions->addWidget(m_wbDownload); hLayout->addWidget(m_wlArtist); hLayout->addWidget(m_wlAlbum); hLayout->setStretch(0, 0); hLayout->setStretch(1, 1); vLayout->addLayout(hLayoutTop); vLayout->addLayout(hLayout); m_mainLayout->addLayout(vLayout, 0, 1); }
void FilterExpressionsPreferencesFrame::on_expressionTreeWidget_itemActivated(QTreeWidgetItem *item, int column) { if (!item || cur_line_edit_) return; QWidget *editor = NULL; cur_column_ = column; switch (column) { case label_col_: { cur_line_edit_ = new QLineEdit(); cur_column_ = column; saved_col_string_ = item->text(label_col_); connect(cur_line_edit_, SIGNAL(editingFinished()), this, SLOT(labelEditingFinished())); editor = cur_line_edit_; break; } case expression_col_: { SyntaxLineEdit *syntax_edit = new SyntaxLineEdit(); saved_col_string_ = item->text(expression_col_); connect(syntax_edit, SIGNAL(textChanged(QString)), this, SLOT(expressionTextChanged(QString))); connect(syntax_edit, SIGNAL(editingFinished()), this, SLOT(expressionEditingFinished())); editor = cur_line_edit_ = syntax_edit; break; } default: return; } if (cur_line_edit_) { cur_line_edit_->setText(saved_col_string_); cur_line_edit_->selectAll(); connect(cur_line_edit_, SIGNAL(destroyed()), this, SLOT(lineEditDestroyed())); } if (editor) { QFrame *edit_frame = new QFrame(); QHBoxLayout *hb = new QHBoxLayout(); QSpacerItem *spacer = new QSpacerItem(5, 10); hb->addWidget(editor, 0); hb->addSpacerItem(spacer); hb->setStretch(1, 1); hb->setContentsMargins(0, 0, 0, 0); edit_frame->setLineWidth(0); edit_frame->setFrameStyle(QFrame::NoFrame); // The documentation suggests setting autoFillbackground. That looks silly // so we clear the item text instead. item->setText(cur_column_, ""); edit_frame->setLayout(hb); ui->expressionTreeWidget->setItemWidget(item, cur_column_, edit_frame); editor->setFocus(); } }
QGroupBox* ScreenSetting::CreateBoxLockScreenSetting() { /*创建窗口*/ m_groupboxDispaySettings = new QGroupBox; /*布局*/ QVBoxLayout* layoutDisplaySetting = new QVBoxLayout(m_groupboxDispaySettings); QHBoxLayout* layoutDisplayLock = new QHBoxLayout(this); QHBoxLayout* layoutLockTime = new QHBoxLayout(this); layoutDisplaySetting->addStretch(1); layoutDisplaySetting->addLayout(layoutLockTime); layoutDisplaySetting->addLayout(layoutDisplayLock); layoutDisplaySetting->addStretch(1); /*创建窗口控件并布局*/ m_lbLockTime = new QLabel; m_ltLockTimeValue = new QLineEdit("16"); m_ltLockTimeValue->setValidator(new QRegExpValidator(QRegExp("[0-9]{1,3}"), m_ltLockTimeValue)); layoutLockTime->addWidget(m_lbLockTime); layoutLockTime->addWidget(m_ltLockTimeValue); layoutLockTime->setStretch(0, 1); layoutLockTime->setStretch(1, 1); m_lbLockScreen = new QLabel; m_btnLockScreen = new Button; connect(m_btnLockScreen, &Button::clicked, this, [this]{ (new DialogLockScreen(this,m_ltLockTimeValue->text().toInt()))->show(); }); layoutDisplayLock->addWidget(m_lbLockScreen); layoutDisplayLock->addWidget(m_btnLockScreen); layoutDisplayLock->setStretch(0, 1); layoutDisplayLock->setStretch(1, 1); return m_groupboxDispaySettings; }
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // MainWindow::createWidgets: // // Create widgets for image display and filter control panels. // void MainWindow::createWidgets() { // assemble image display widget and control panel in horizontal layout QHBoxLayout *hbox = new QHBoxLayout; hbox->addWidget(createGroupDisplay()); hbox->addWidget(createGroupPanel()); hbox->setStretch(0, 1); // create container widget and set its layout QWidget *w = new QWidget; w->setLayout(hbox); // set central widget so that it can be displayed setCentralWidget(w); }
QLayout * PageSinglePlayer::footerLayoutDefinition() { QHBoxLayout * bottomLine = new QHBoxLayout(); bottomLine->addStretch(); BtnDemos = addButton(":/res/Record.png", bottomLine, 1, true); BtnDemos->setWhatsThis(tr("Watch recorded demos")); BtnLoad = addButton(":/res/Load.png", bottomLine, 2, true); BtnLoad->setStyleSheet("QPushButton{margin: 24px 0 0 0;}"); BtnLoad->setWhatsThis(tr("Load a previously saved game")); bottomLine->setStretch(1,0); bottomLine->setStretch(2,0); bottomLine->setAlignment(BtnDemos, Qt::AlignRight | Qt::AlignBottom); bottomLine->setAlignment(BtnLoad, Qt::AlignRight | Qt::AlignBottom); return bottomLine; }
void CScreenLineEditor::InitLayout() { /*第一行*/ QHBoxLayout* layoutTop = new QHBoxLayout; m_btnForward = new CButton; m_btnBackward = new CButton; m_lineEditor = new CLineEditor(); layoutTop->addWidget(m_btnForward); layoutTop->addWidget(m_lineEditor); layoutTop->addWidget(m_btnBackward); layoutTop->setStretch(1, 1); /*第二行*/ m_screenBottom = new CScreenBottom; m_btnVariable = new CButton; m_btnMacro = new CButton; m_btnKeyboard = new CButton; m_btnAdd = new CButton; m_btnDelete = new CButton; m_btnConfirm = new CButton; m_btnBack = new CButton; QList<CButton*> btnList; btnList.append(m_btnVariable); btnList.append(m_btnMacro); btnList.append(m_btnKeyboard); btnList.append(m_btnAdd); btnList.append(m_btnDelete); btnList.append(m_btnConfirm); btnList.append(m_btnBack); m_screenBottom->AddButtonList(btnList); /*全部*/ QVBoxLayout* layoutMain = new QVBoxLayout(this); layoutMain->setMargin(0); layoutMain->setSpacing(0); layoutMain->addLayout(layoutTop); layoutMain->addLayout(m_screenBottom); }
QPolarCoordinateEdit::QPolarCoordinateEdit(const QString & name, QWidget *parent) : QWidget(parent) { m_name = new QLabel(name, this); m_phi = new QAngleEdit(tr("Phi"), this); m_theta = new QAngleEdit(tr("Theta"), this); m_theta->setMin(-1.57); m_theta->setMax(1.57); QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(m_name); layout->addWidget(m_phi); layout->addWidget(m_theta); layout->setStretch(0, 1); layout->setSpacing(0); setLayout(layout); connect(m_phi, SIGNAL(valueChanged(double)), this, SLOT(sendPhi(double))); connect(m_theta, SIGNAL(valueChanged(double)), this, SLOT(sendTheta(double))); }
QLayout * PageMain::footerLayoutDefinition() { QHBoxLayout * bottomLayout = new QHBoxLayout(); mainNote = new QLabel(this); mainNote->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); mainNote->setWordWrap(true); bottomLayout->addWidget(mainNote, 0); bottomLayout->setStretch(0,1); btnBack->setWhatsThis(tr("Exit game")); #ifdef VIDEOREC BtnVideos = addButton(":/res/Videos.png", bottomLayout, 1, true); BtnVideos->setWhatsThis(tr("Manage videos recorded from game")); #endif BtnSetup = addButton(":/res/Settings.png", bottomLayout, 2, true); BtnSetup->setWhatsThis(tr("Edit game preferences")); return bottomLayout; }
Dialog_Names::Dialog_Names(QWidget *parent, QString iTitle, int iPos): QDialog(parent) { Pos = iPos; Title = iTitle; setWindowTitle(Title); QVBoxLayout *layoutLayout = new QVBoxLayout(); QHBoxLayout *fieldsLayout = new QHBoxLayout(); QHBoxLayout *buttonLayout = new QHBoxLayout(); ValueEdit = new QLineEdit(); ValueEdit->setMaxLength(128); fieldsLayout->addWidget(new QLabel(tr("Наименование: "))); fieldsLayout->addWidget(ValueEdit); fieldsLayout->setStretch(1,1); layoutLayout->addLayout(fieldsLayout); QDialogButtonBox *buttonBox = new QDialogButtonBox(); QPushButton *closeButton = new QPushButton(tr("&Отмена")); QPushButton *submitButton = new QPushButton(tr("&Далее")); closeButton->setDefault(true); connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); connect(submitButton, SIGNAL(clicked()), this, SLOT(submit())); buttonBox->addButton(submitButton, QDialogButtonBox::ResetRole); buttonBox->addButton(closeButton, QDialogButtonBox::RejectRole); buttonLayout->addStretch(1); buttonLayout->addWidget(buttonBox); layoutLayout->addLayout(buttonLayout); setLayout(layoutLayout); setMinimumSize(420,100); // загрузка Global.DataQuery.prepare("SELECT \"Name\" FROM public.\"RubricaNames\" WHERE \"Id\"=:Id;"); Global.DataQuery.bindValue(":Id",Pos); if (!Global.DataQuery.exec()) { GuiSqlErrorData("Ошибка работы с базой данных!"); return; } QSqlRecord R = Global.DataQuery.record(); if (!Global.DataQuery.next()) { GuiSqlErrorData("Ошибка работы с базой данных!"); return; } OldValue = Global.DataQuery.value(R.indexOf("Name")).toString().trimmed(); ValueEdit->setText(OldValue); }
void setupUi(QWidget *Ui_CPicScrollWidget) { if (Ui_CPicScrollWidget->objectName().isEmpty()) Ui_CPicScrollWidget->setObjectName(QString::fromUtf8("Ui_CPicScrollWidget")); Ui_CPicScrollWidget->resize(672, 322); horizontalLayout = new QHBoxLayout(Ui_CPicScrollWidget); horizontalLayout->setSpacing(0); horizontalLayout->setContentsMargins(0, 0, 0, 0); horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); PicFlow = new CPicFlowWidget(Ui_CPicScrollWidget); PicFlow->setObjectName(QString::fromUtf8("PicFlow")); QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(PicFlow->sizePolicy().hasHeightForWidth()); PicFlow->setSizePolicy(sizePolicy); PicFlow->setStyleSheet(QString::fromUtf8("background-color: rgb(144, 178, 196)")); horizontalLayout->addWidget(PicFlow); Scroll = new CScrollWidget(Ui_CPicScrollWidget); Scroll->setObjectName(QString::fromUtf8("Scroll")); QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Preferred); sizePolicy1.setHorizontalStretch(0); sizePolicy1.setVerticalStretch(0); sizePolicy1.setHeightForWidth(Scroll->sizePolicy().hasHeightForWidth()); Scroll->setSizePolicy(sizePolicy1); Scroll->setMinimumSize(QSize(150, 0)); horizontalLayout->addWidget(Scroll); horizontalLayout->setStretch(0, 3); horizontalLayout->setStretch(1, 1); retranslateUi(Ui_CPicScrollWidget); QMetaObject::connectSlotsByName(Ui_CPicScrollWidget); } // setupUi
QWidget *UnseenEpisodeWidget::_makeWidget() { if (_serie["unseen"].toList().isEmpty()) { _currentId = -1; return 0; // TODO DO IT RIGHT !!! } QVariantList unseenEpisodes = _serie["unseen"].toList(); QVariantMap episode = unseenEpisodes.takeFirst().toMap(); _serie["unseen"] = unseenEpisodes; QString episodeTitle = episode["title"].toString(); QString episodeCode = episode["code"].toString(); _currentId = episode["id"].toDouble(); QWidget *widget = new QWidget(this); QHBoxLayout *layout = new QHBoxLayout; layout->setContentsMargins(5, 5, 5, 5); QLabel *episodeLabel = new QLabel(widget); episodeLabel->setWordWrap(true); episodeLabel->setText(_serie["title"].toString() + " - " + episodeCode + " - " + episodeTitle); layout->addWidget(episodeLabel); MarkAsButton *button = new MarkAsButton(_currentId, widget); connect(button, SIGNAL(episodeSeenClicked(uint)), _api, SLOT(postEpisodesWatched(uint))); layout->addWidget(button); layout->setStretch(0, 1); widget->setLayout(layout); widget->setEnabled(false); return widget; }
void RTIMULibDemo::layoutWindow() { QVBoxLayout *vLayout = new QVBoxLayout(); vLayout->setContentsMargins(3, 3, 3, 3); vLayout->setSpacing(3); QHBoxLayout *imuLayout = new QHBoxLayout(); vLayout->addLayout(imuLayout); imuLayout->addWidget(new QLabel("IMU type: ")); m_imuType = new QLabel(); imuLayout->addWidget(m_imuType); imuLayout->setStretch(1, 1); vLayout->addSpacing(10); QHBoxLayout *biasLayout = new QHBoxLayout(); vLayout->addLayout(biasLayout); biasLayout->addWidget(new QLabel("Gyro bias status: ")); m_biasStatus = new QLabel(); biasLayout->addWidget(m_biasStatus); biasLayout->setStretch(1, 1); vLayout->addSpacing(10); vLayout->addWidget(new QLabel("Fusion state (quaternion): ")); QHBoxLayout *dataLayout = new QHBoxLayout(); dataLayout->setAlignment(Qt::AlignLeft); m_fusionQPoseScalar = getFixedPanel("1"); m_fusionQPoseX = getFixedPanel("0"); m_fusionQPoseY = getFixedPanel("0"); m_fusionQPoseZ = getFixedPanel("0"); dataLayout->addSpacing(30); dataLayout->addWidget(m_fusionQPoseScalar); dataLayout->addWidget(m_fusionQPoseX); dataLayout->addWidget(m_fusionQPoseY); dataLayout->addWidget(m_fusionQPoseZ); vLayout->addLayout(dataLayout); vLayout->addSpacing(10); vLayout->addWidget(new QLabel("Pose - roll, pitch, yaw (degrees): ")); m_fusionPoseX = getFixedPanel("0"); m_fusionPoseY = getFixedPanel("0"); m_fusionPoseZ = getFixedPanel("0"); dataLayout = new QHBoxLayout(); dataLayout->setAlignment(Qt::AlignLeft); dataLayout->addSpacing(30); dataLayout->addWidget(m_fusionPoseX); dataLayout->addWidget(m_fusionPoseY); dataLayout->addWidget(m_fusionPoseZ); vLayout->addLayout(dataLayout); vLayout->addSpacing(10); vLayout->addWidget(new QLabel("Gyros (radians/s): ")); m_gyroX = getFixedPanel("0"); m_gyroY = getFixedPanel("0"); m_gyroZ = getFixedPanel("0"); dataLayout = new QHBoxLayout(); dataLayout->setAlignment(Qt::AlignLeft); dataLayout->addSpacing(30); dataLayout->addWidget(m_gyroX); dataLayout->addWidget(m_gyroY); dataLayout->addWidget(m_gyroZ); vLayout->addLayout(dataLayout); vLayout->addSpacing(10); vLayout->addWidget(new QLabel("Accelerometers (g): ")); m_accelX = getFixedPanel("0"); m_accelY = getFixedPanel("0"); m_accelZ = getFixedPanel("0"); dataLayout = new QHBoxLayout(); dataLayout->addSpacing(30); dataLayout->setAlignment(Qt::AlignLeft); dataLayout->addWidget(m_accelX); dataLayout->addWidget(m_accelY); dataLayout->addWidget(m_accelZ); vLayout->addLayout(dataLayout); vLayout->addSpacing(10); vLayout->addWidget(new QLabel("Accelerometer magnitude (g): ")); m_accelMagnitude = getFixedPanel("0"); dataLayout = new QHBoxLayout(); dataLayout->addSpacing(30); dataLayout->addWidget(m_accelMagnitude); dataLayout->setAlignment(Qt::AlignLeft); vLayout->addLayout(dataLayout); vLayout->addSpacing(10); vLayout->addWidget(new QLabel("Accelerometer residuals (g): ")); m_accelResidualX = getFixedPanel("0"); m_accelResidualY = getFixedPanel("0"); m_accelResidualZ = getFixedPanel("0"); dataLayout = new QHBoxLayout(); dataLayout->addSpacing(30); dataLayout->setAlignment(Qt::AlignLeft); dataLayout->addWidget(m_accelResidualX); dataLayout->addWidget(m_accelResidualY); dataLayout->addWidget(m_accelResidualZ); vLayout->addLayout(dataLayout); vLayout->addSpacing(10); vLayout->addWidget(new QLabel("Magnetometers (uT): ")); m_compassX = getFixedPanel("0"); m_compassY = getFixedPanel("0"); m_compassZ = getFixedPanel("0"); dataLayout = new QHBoxLayout(); dataLayout->setAlignment(Qt::AlignLeft); dataLayout->addSpacing(30); dataLayout->addWidget(m_compassX); dataLayout->addWidget(m_compassY); dataLayout->addWidget(m_compassZ); vLayout->addLayout(dataLayout); vLayout->addSpacing(10); vLayout->addWidget(new QLabel("Compass magnitude (uT): ")); m_compassMagnitude = getFixedPanel("0"); dataLayout = new QHBoxLayout(); dataLayout->addSpacing(30); dataLayout->addWidget(m_compassMagnitude); dataLayout->setAlignment(Qt::AlignLeft); vLayout->addLayout(dataLayout); vLayout->addSpacing(10); vLayout->addWidget(new QLabel("Pressure (hPa), height above sea level (m): ")); m_pressure = getFixedPanel("0"); m_height = getFixedPanel("0"); dataLayout = new QHBoxLayout(); dataLayout->addSpacing(30); dataLayout->addWidget(m_pressure); dataLayout->addWidget(m_height); dataLayout->setAlignment(Qt::AlignLeft); vLayout->addLayout(dataLayout); vLayout->addSpacing(10); vLayout->addWidget(new QLabel("Temperature (C): ")); m_temperature = getFixedPanel("0"); dataLayout = new QHBoxLayout(); dataLayout->addSpacing(30); dataLayout->addWidget(m_temperature); dataLayout->setAlignment(Qt::AlignLeft); vLayout->addLayout(dataLayout); vLayout->addSpacing(10); vLayout->addWidget(new QLabel("Humidity (RH): ")); m_humidity = getFixedPanel("0"); dataLayout = new QHBoxLayout(); dataLayout->addSpacing(30); dataLayout->addWidget(m_humidity); dataLayout->setAlignment(Qt::AlignLeft); vLayout->addLayout(dataLayout); vLayout->addSpacing(10); QHBoxLayout *fusionBox = new QHBoxLayout(); QLabel *fusionTypeLabel = new QLabel("Fusion algorithm: "); fusionBox->addWidget(fusionTypeLabel); fusionTypeLabel->setMaximumWidth(150); m_fusionType = new QLabel(); fusionBox->addWidget(m_fusionType); vLayout->addLayout(fusionBox); vLayout->addSpacing(10); vLayout->addWidget(new QLabel("Fusion controls: ")); m_enableGyro = new QCheckBox("Enable gyros"); m_enableGyro->setChecked(true); vLayout->addWidget(m_enableGyro); m_enableAccel = new QCheckBox("Enable accels"); m_enableAccel->setChecked(true); vLayout->addWidget(m_enableAccel); m_enableCompass = new QCheckBox("Enable compass"); m_enableCompass->setChecked(true); vLayout->addWidget(m_enableCompass); m_enableDebug = new QCheckBox("Enable debug messages"); m_enableDebug->setChecked(false); vLayout->addWidget(m_enableDebug); vLayout->addStretch(1); centralWidget()->setLayout(vLayout); setFixedSize(850, 750); }
KeyBinder::KeyBinder(QWidget * parent, const QString & helpText, const QString & defaultText, const QString & resetButtonText) : QWidget(parent) { this->defaultText = defaultText; enableSignal = false; // Two-column tab layout QHBoxLayout * pageKeysLayout = new QHBoxLayout(this); pageKeysLayout->setSpacing(0); pageKeysLayout->setContentsMargins(0, 0, 0, 0); // Table for category list QVBoxLayout * catListContainer = new QVBoxLayout(); catListContainer->setContentsMargins(10, 10, 10, 10); catList = new QListWidget(); catList->setFixedWidth(180); catList->setStyleSheet("QListWidget::item { font-size: 14px; } QListWidget:hover { border-color: #F6CB1C; } QListWidget::item:selected { background: #150A61; color: yellow; }"); catList->setFocusPolicy(Qt::NoFocus); connect(catList, SIGNAL(currentRowChanged(int)), this, SLOT(changeBindingsPage(int))); catListContainer->addWidget(catList); pageKeysLayout->addLayout(catListContainer); // Reset all binds button if (!resetButtonText.isEmpty()) { QPushButton * btnResetAll = new QPushButton(resetButtonText); catListContainer->addWidget(btnResetAll); btnResetAll->setFixedHeight(40); catListContainer->setStretch(1, 0); catListContainer->setSpacing(10); connect(btnResetAll, SIGNAL(clicked()), this, SIGNAL(resetAllBinds())); } // Container for pages of key bindings QWidget * bindingsPagesContainer = new QWidget(); QVBoxLayout * rightLayout = new QVBoxLayout(bindingsPagesContainer); // Scroll area for key bindings QScrollArea * scrollArea = new QScrollArea(); scrollArea->setContentsMargins(0, 0, 0, 0); scrollArea->setWidget(bindingsPagesContainer); scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); scrollArea->setWidgetResizable(true); scrollArea->setFrameShape(QFrame::NoFrame); scrollArea->setStyleSheet("background: #130F2A;"); // Add key binding pages to bindings tab pageKeysLayout->addWidget(scrollArea); pageKeysLayout->setStretch(1, 1); // Custom help text QLabel * helpLabel = new QLabel(); helpLabel->setText(helpText); helpLabel->setStyleSheet("color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; border-radius: 10px; padding: auto 20px;"); helpLabel->setFixedHeight(24); rightLayout->addWidget(helpLabel, 0, Qt::AlignCenter); // Category list and bind table row heights const int rowHeight = 20; QSize catSize, headerSize; catSize.setHeight(36); headerSize.setHeight(24); // Category list header QListWidgetItem * catListHeader = new QListWidgetItem(tr("Category")); catListHeader->setSizeHint(headerSize); catListHeader->setFlags(Qt::NoItemFlags); catListHeader->setForeground(QBrush(QColor("#130F2A"))); catListHeader->setBackground(QBrush(QColor("#F6CB1C"))); catListHeader->setTextAlignment(Qt::AlignCenter); catList->addItem(catListHeader); // Populate bindingsPages = new QHBoxLayout(); bindingsPages->setContentsMargins(0, 0, 0, 0); rightLayout->addLayout(bindingsPages); QWidget * curPage = NULL; QVBoxLayout * curLayout = NULL; QTableWidget * curTable = NULL; bool bFirstPage = true; selectedBindTable = NULL; bindComboBoxCellMappings = new QHash<QObject *, QTableWidgetItem *>(); bindCellComboBoxMappings = new QHash<QTableWidgetItem *, QComboBox *>(); for (int i = 0; i < BINDS_NUMBER; i++) { if (cbinds[i].category != NULL) { // Add stretch at end of previous layout if (curLayout != NULL) curLayout->insertStretch(-1, 1); // Category list item QListWidgetItem * catItem = new QListWidgetItem(HWApplication::translate("binds (categories)", cbinds[i].category)); catItem->setSizeHint(catSize); catList->addItem(catItem); // Create new page curPage = new QWidget(); curLayout = new QVBoxLayout(curPage); curLayout->setSpacing(2); bindingsPages->addWidget(curPage); if (!bFirstPage) curPage->setVisible(false); } // Description if (cbinds[i].description != NULL) { QLabel * desc = new QLabel(HWApplication::translate("binds (descriptions)", cbinds[i].description)); curLayout->addWidget(desc, 0); QFrame * divider = new QFrame(); divider->setFrameShape(QFrame::HLine); divider->setFrameShadow(QFrame::Plain); curLayout->addWidget(divider, 0); } // New table if (cbinds[i].category != NULL || cbinds[i].description != NULL) { curTable = new QTableWidget(0, 2); curTable->verticalHeader()->setVisible(false); curTable->horizontalHeader()->setVisible(false); curTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); curTable->verticalHeader()->setDefaultSectionSize(rowHeight); curTable->setShowGrid(false); curTable->setStyleSheet("QTableWidget { border: none; } "); curTable->setSelectionBehavior(QAbstractItemView::SelectRows); curTable->setSelectionMode(QAbstractItemView::SingleSelection); curTable->setFocusPolicy(Qt::NoFocus); connect(curTable, SIGNAL(itemSelectionChanged()), this, SLOT(bindSelectionChanged())); connect(curTable, SIGNAL(itemClicked(QTableWidgetItem *)), this, SLOT(bindCellClicked(QTableWidgetItem *))); curLayout->addWidget(curTable, 0); } // Hidden combo box QComboBox * comboBox = CBBind[i] = new QComboBox(curTable); comboBox->setModel((QAbstractItemModel*)DataManager::instance().bindsModel()); comboBox->setVisible(false); comboBox->setFixedWidth(200); // Table row int row = curTable->rowCount(); QTableWidgetItem * nameCell = new QTableWidgetItem(HWApplication::translate("binds", cbinds[i].name)); nameCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); curTable->insertRow(row); curTable->setItem(row, 0, nameCell); QTableWidgetItem * bindCell = new QTableWidgetItem(comboBox->currentText()); bindCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); curTable->setItem(row, 1, bindCell); curTable->resizeColumnsToContents(); curTable->setFixedHeight(curTable->verticalHeader()->length() + 10); // Updates the text in the table cell connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(bindChanged(const QString &))); // Map combo box and that row's cells to each other bindComboBoxCellMappings->insert(comboBox, bindCell); bindCellComboBoxMappings->insert(nameCell, comboBox); bindCellComboBoxMappings->insert(bindCell, comboBox); }
CGraphicsConfig::CGraphicsConfig(QWidget *parent, CConfiguration *configuration, CInternationalization *internationalization, QUndoStack *undoStack) : QWidget(parent), m_Configuration(configuration), m_Internationalization(internationalization), m_UndoStack(undoStack), m_DriverGroup(NULL), m_Enabled(NULL), m_DriverLabel(NULL), m_Driver(NULL), m_FontNameLabel(NULL), m_FontName(NULL), m_Apply(NULL), m_RenderGroup(NULL), m_BackgroundColor(NULL), m_FontShadow(NULL), m_ScreenshotGroup(NULL) { nlassert(m_Configuration); nlassert(m_Internationalization); nlassert(m_UndoStack); QVBoxLayout *vboxLayout = new QVBoxLayout(); // Driver { nlassert(!m_DriverGroup); m_DriverGroup = new QGroupBox(); QVBoxLayout *groupVboxLayout = new QVBoxLayout(); // Enabled { nlassert(!m_Enabled); m_Enabled = new QCheckBox(); groupVboxLayout->addWidget(m_Enabled); } // Driver { QHBoxLayout *hboxLayout = new QHBoxLayout(); nlassert(!m_DriverLabel); m_DriverLabel = new QLabel(); nlassert(!m_Driver); m_Driver = new QComboBox(); m_DriverLabel->setBuddy(m_Driver); hboxLayout->addWidget(m_DriverLabel); hboxLayout->addWidget(m_Driver); hboxLayout->setStretch(1, 1); groupVboxLayout->addLayout(hboxLayout); } // Font Name { QHBoxLayout *hboxLayout = new QHBoxLayout(); nlassert(!m_FontNameLabel); m_FontNameLabel = new QLabel(); nlassert(!m_FontName); m_FontName = new QLineEdit(); m_FontNameLabel->setBuddy(m_FontName); hboxLayout->addWidget(m_FontNameLabel); hboxLayout->addWidget(m_FontName); hboxLayout->setStretch(1, 1); groupVboxLayout->addLayout(hboxLayout); } // Apply { nlassert(!m_Apply); m_Apply = new QPushButton(); m_Apply->setDefault(true); groupVboxLayout->addWidget(m_Apply); connect(m_Apply, SIGNAL(pressed()), this, SLOT(applyPressed())); } m_DriverGroup->setLayout(groupVboxLayout); vboxLayout->addWidget(m_DriverGroup); } // Render { nlassert(!m_RenderGroup); m_RenderGroup = new QGroupBox(); QVBoxLayout *groupVboxLayout = new QVBoxLayout(); // Background Color { m_BackgroundColor = new QtColorPicker(); m_BackgroundColor->setStandardColors(); groupVboxLayout->addWidget(m_BackgroundColor); connect(m_BackgroundColor, SIGNAL(colorChanged(const QColor &)), this, SLOT(uicbBackgroundColor(const QColor &))); } // Font Shadow { nlassert(!m_FontShadow); m_FontShadow = new QCheckBox(); groupVboxLayout->addWidget(m_FontShadow); connect(m_FontShadow, SIGNAL(toggled(bool)), this, SLOT(uicbFontShadow(bool))); } m_RenderGroup->setLayout(groupVboxLayout); vboxLayout->addWidget(m_RenderGroup); } // Screenshots { nlassert(!m_ScreenshotGroup); m_ScreenshotGroup = new QGroupBox(); QVBoxLayout *groupVboxLayout = new QVBoxLayout(); m_ScreenshotGroup->setLayout(groupVboxLayout); vboxLayout->addWidget(m_ScreenshotGroup); } vboxLayout->addStretch(); setLayout(vboxLayout); // setup config file callbacks and initialize values m_Configuration->setAndCallback("GraphicsEnabled", CConfigCallback(this, &CGraphicsConfig::cfcbGraphicsEnabled)); m_Configuration->setCallback("GraphicsDriver", CConfigCallback(this, &CGraphicsConfig::cfcbGraphicsDriver)); m_Configuration->setAndCallback("GraphicsDrivers", CConfigCallback(this, &CGraphicsConfig::cfcbGraphicsDrivers)); m_Configuration->setAndCallback("FontName", CConfigCallback(this, &CGraphicsConfig::cfcbFontName)); m_Configuration->setAndCallback("BackgroundColor", CConfigCallback(this, &CGraphicsConfig::cfcbBackgroundColor)); m_Configuration->setAndCallback("FontShadow", CConfigCallback(this, &CGraphicsConfig::cfcbFontShadow)); // setup translation callback and initialize translation m_Internationalization->enableCallback(CEmptyCallback(this, &CGraphicsConfig::incbTranslate)); incbTranslate(); // setup undo/redo automation CUndoRedoBinderButton *undoRedoEnabled = new CUndoRedoBinderButton(m_Enabled, undoStack); CUndoRedoBinderComboBox *undoRedoDriver = new CUndoRedoBinderComboBox(m_Driver, undoStack); CUndoRedoBinderLineEdit *undoRedoFontName = new CUndoRedoBinderLineEdit(m_FontName, undoStack); CUndoRedoBinderColorPicker *undoRedoBackgroundColor = new CUndoRedoBinderColorPicker(m_BackgroundColor, undoStack); CUndoRedoBinderButton *undoRedoFontShadow = new CUndoRedoBinderButton(m_FontShadow, undoStack); }
void ColumnPreferencesFrame::on_columnTreeWidget_itemActivated(QTreeWidgetItem *item, int column) { if (!item || cur_line_edit_ || cur_combo_box_) return; QWidget *editor = NULL; cur_column_ = column; saved_combo_idx_ = item->data(type_col_, Qt::UserRole).toInt(); switch (column) { case title_col_: { cur_line_edit_ = new QLineEdit(); cur_column_ = column; saved_col_string_ = item->text(title_col_); connect(cur_line_edit_, SIGNAL(editingFinished()), this, SLOT(columnTitleEditingFinished())); editor = cur_line_edit_; break; } case type_col_: { cur_combo_box_ = new QComboBox(); for (int i = 0; i < NUM_COL_FMTS; i++) { cur_combo_box_->addItem(col_format_desc(i), QVariant(i)); if (i == saved_combo_idx_) { cur_combo_box_->setCurrentIndex(i); } } connect(cur_combo_box_, SIGNAL(currentIndexChanged(int)), this, SLOT(columnTypeCurrentIndexChanged(int))); editor = cur_combo_box_; break; } case custom_field_col_: { SyntaxLineEdit *syntax_edit = new SyntaxLineEdit(); saved_col_string_ = item->text(custom_field_col_); connect(syntax_edit, SIGNAL(textChanged(QString)), syntax_edit, SLOT(checkFieldName(QString))); connect(syntax_edit, SIGNAL(editingFinished()), this, SLOT(customFieldEditingFinished())); editor = cur_line_edit_ = syntax_edit; saved_combo_idx_ = item->data(type_col_, Qt::UserRole).toInt(); item->setText(type_col_, col_format_desc(COL_CUSTOM)); item->setData(type_col_, Qt::UserRole, QVariant(COL_CUSTOM)); break; } case custom_occurrence_col_: { SyntaxLineEdit *syntax_edit = new SyntaxLineEdit(); saved_col_string_ = item->text(custom_occurrence_col_); connect(syntax_edit, SIGNAL(textChanged(QString)), this, SLOT(customOccurrenceTextChanged(QString))); connect(syntax_edit, SIGNAL(editingFinished()), this, SLOT(customOccurrenceEditingFinished())); editor = cur_line_edit_ = syntax_edit; saved_combo_idx_ = item->data(type_col_, Qt::UserRole).toInt(); item->setText(type_col_, col_format_desc(COL_CUSTOM)); item->setData(type_col_, Qt::UserRole, QVariant(COL_CUSTOM)); break; } default: return; } if (cur_line_edit_) { cur_line_edit_->setText(saved_col_string_); cur_line_edit_->selectAll(); connect(cur_line_edit_, SIGNAL(destroyed()), this, SLOT(lineEditDestroyed())); } if (cur_combo_box_) { connect(cur_combo_box_, SIGNAL(destroyed()), this, SLOT(comboDestroyed())); } if (editor) { QFrame *edit_frame = new QFrame(); QHBoxLayout *hb = new QHBoxLayout(); QSpacerItem *spacer = new QSpacerItem(5, 10); hb->addWidget(editor, 0); hb->addSpacerItem(spacer); hb->setStretch(1, 1); hb->setContentsMargins(0, 0, 0, 0); edit_frame->setLineWidth(0); edit_frame->setFrameStyle(QFrame::NoFrame); // The documentation suggests setting autoFillbackground. That looks silly // so we clear the item text instead. item->setText(cur_column_, ""); edit_frame->setLayout(hb); ui->columnTreeWidget->setItemWidget(item, cur_column_, edit_frame); editor->setFocus(); } }
PhysicsControl::PhysicsControl(QWidget *parent) : QDialog(parent) { setWindowTitle(tr("Physics Control")); m_youngModulusValue = new QDoubleEditSlider(tr("Young's modulus"), this); m_youngModulusValue->setLimit(40000.0, 800000.0); m_youngModulusValue->setValue(160000.0); YGrp = new QGroupBox; QHBoxLayout * yLayout = new QHBoxLayout; yLayout->addWidget(m_youngModulusValue); yLayout->setStretch(1, 1); YGrp->setLayout(yLayout); stiffnessCurveLabel = new QLabel(tr("Stiffness curve")); m_youngAttenuateValue = new QSplineEdit(this); yAGrp = new QGroupBox; QVBoxLayout * yaLayout = new QVBoxLayout; yaLayout->addWidget(stiffnessCurveLabel); yaLayout->addWidget(m_youngAttenuateValue); yaLayout->setStretch(1, 1); yAGrp->setLayout(yaLayout); m_densityValue = new QDoubleEditSlider(tr("Density"), this); m_densityValue->setLimit(0.1, 200.0); m_densityValue->setValue(100.0); dsGrp = new QGroupBox; QVBoxLayout * dsLayout = new QVBoxLayout; dsLayout->addWidget(m_densityValue); dsLayout->setStretch(1, 1); dsGrp->setLayout(dsLayout); m_windSpeedValue = new QDoubleEditSlider(tr("Wind speed"), this); m_windSpeedValue->setLimit(0.0, 30.0); m_windSpeedValue->setValue(0.0); m_windVecValue = new QPolarCoordinateEdit(tr("Wind vector"), this); QGroupBox * windGrp = new QGroupBox; QVBoxLayout * windLayout = new QVBoxLayout; windLayout->addWidget(m_windVecValue); windLayout->addWidget(m_windSpeedValue); windLayout->setStretch(1, 1); windLayout->setSpacing(2); windGrp->setLayout(windLayout); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(dsGrp); layout->addWidget(YGrp); layout->addWidget(yAGrp); layout->addWidget(windGrp); layout->setStretch(3, 1); layout->setSpacing(4); setLayout(layout); connect(m_densityValue, SIGNAL(valueChanged(double)), this, SLOT(sendDensity(double))); connect(m_youngModulusValue, SIGNAL(valueChanged(double)), this, SLOT(sendYoungModulus(double))); connect(m_youngAttenuateValue, SIGNAL(valueChanged(QPointF)), this, SLOT(sendStiffnessAttenuateEnds(QPointF))); connect(m_youngAttenuateValue, SIGNAL(leftControlChanged(QPointF)), this, SLOT(sendStiffnessAttenuateLeft(QPointF))); connect(m_youngAttenuateValue, SIGNAL(rightControlChanged(QPointF)), this, SLOT(sendStiffnessAttenuateRight(QPointF))); connect(m_windSpeedValue, SIGNAL(valueChanged(double)), this, SLOT(sendWindSpeed(double))); connect(m_windVecValue, SIGNAL(valueChanged(QPointF)), this, SLOT(sendWindVec(QPointF))); }