void TaskDatumParameters::updateRefButton(int idx) { QAbstractButton* b; switch(idx){ case 0: b = ui->buttonRef1; break; case 1: b = ui->buttonRef2; break; case 2: b = ui->buttonRef3; break; case 3: b = ui->buttonRef4; break; default: throw Base::Exception("button index out of range"); } Part::Datum* pcDatum = static_cast<Part::Datum*>(DatumView->getObject()); std::vector<App::DocumentObject*> refs = pcDatum->Support.getValues(); int numrefs = refs.size(); bool enable = true; if (idx > numrefs) enable = false; if (idx == numrefs && this->lastSuggestResult.nextRefTypeHint.size() == 0) enable = false; b->setEnabled(enable); b->setChecked(iActiveRef == idx); if (iActiveRef == idx) { b->setText(tr("Selecting...")); } else if (idx < static_cast<int>(this->lastSuggestResult.references_Types.size())){ b->setText(AttacherGui::getShapeTypeText(this->lastSuggestResult.references_Types[idx])); } else { b->setText(tr("Reference%1").arg(idx+1)); } }
XMLInfoDialog::XMLInfoDialog(QWidget *parent) : QDialog(parent), ui(new Ui::XMLInfoDialog) { ui->setupUi(this); setWindowTitle(tr("选择订阅")); setMinimumWidth(400); setMinimumHeight(450); setMaximumWidth(400); setMaximumHeight(450); QAbstractButton *okBtn = ui->buttonBox->button(QDialogButtonBox::Ok); QAbstractButton *cancelBtn = ui->buttonBox->button(QDialogButtonBox::Cancel); okBtn->setText(tr("确定")); cancelBtn->setText(tr("取消")); connect(cancelBtn, SIGNAL(clicked(bool)), this, SLOT(close())); connect(okBtn, SIGNAL(clicked(bool)), this, SLOT(subscriptionSelectedFinished())); QHeaderView *header = new QHeaderView(Qt::Horizontal, ui->treeWidget); header->setSectionResizeMode(QHeaderView::Stretch); header->setDefaultAlignment(Qt::AlignCenter); ui->treeWidget->setHeader(header); connect(ui->treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(treeItemChanged(QTreeWidgetItem*,int))); }
void wxRadioBox::SetString(unsigned int n, const wxString& s) { QAbstractButton *qtButton = GetButtonAt( m_qtButtonGroup, n ); wxCHECK_RET( qtButton != NULL, INVALID_INDEX_MESSAGE ); qtButton->setText( wxQtConvertString( s )); }
void EmailAccountWizardOutgoingServerPage::testButtonClicked(int which) { Q_D(EmailAccountWizardOutgoingServerPage); Q_ASSERT(which == QWizard::CustomButton1); if (which != QWizard::CustomButton1) return; EmailAccountWizard* w = static_cast<EmailAccountWizard*>(wizard()); Q_ASSERT(w); if (!w) return; if (w->currentId() != EmailAccountWizard::PageEmailOutgoingServer) return; QAbstractButton* testButton = w->button(QWizard::CustomButton1); Q_ASSERT(testButton); if (!testButton) return; w->updateTestButton(EmailAccountWizard::TestButtonRed); testButton->setText(tr("Testing...")); d->changedDuringTest = false; QFuture<bool> future = QtConcurrent::run(this, &EmailAccountWizardOutgoingServerPage::test); ForgettableWatcher<bool>* futureWatcher = new ForgettableWatcher<bool>(); connect(futureWatcher, SIGNAL(finished()), this, SLOT(testFinished())); futureWatcher->setFuture(future); }
QAbstractButton* FirstRunWizard::setButton( Button button, const QString& text ) { QAbstractButton* returnButton; switch ( button ) { case CustomButton: returnButton = ui->custom; break; case BackButton: returnButton = ui->back; break; case SkipButton: returnButton = ui->skip; break; case NextButton: returnButton = ui->next; break; case FinishButton: returnButton = ui->finish; break; } returnButton->setText( text ); returnButton->show(); return returnButton; }
void Game_main::whoWin()//直接判断white_win,black_win弹出窗口 { if(white_win) { QDialog *Dblack = new QDialog(); QVBoxLayout *vlayout = new QVBoxLayout; Dblack->setFixedSize(150,140); QLabel *label = new QLabel("白棋胜利!"); QAbstractButton *bExit = new QPushButton("再来一局"); bExit->setText("再来一局"); vlayout->addWidget(label); vlayout->addWidget(bExit); Dblack->setLayout(vlayout); Dblack->show(); Dblack->connect(bExit,SIGNAL(clicked()),Dblack,SLOT(close())); Dblack->connect(bExit,SIGNAL(clicked()),this,SLOT(start())); is_over = true; } if(black_win) { QDialog *Dblack = new QDialog(); QVBoxLayout *vlayout = new QVBoxLayout; Dblack->setFixedSize(150,140); QLabel *label = new QLabel("黑棋胜利!"); QAbstractButton *bExit = new QPushButton("再来一局"); bExit->setText("再来一局"); vlayout->addWidget(label); vlayout->addWidget(bExit); Dblack->setLayout(vlayout); Dblack->show(); Dblack->connect(bExit,SIGNAL(clicked()),Dblack,SLOT(close())); Dblack->connect(bExit,SIGNAL(clicked()),this,SLOT(start())); is_over =true; } }
void PageNavigator::setButtonPageNumbers(int lowestPageNum) { OS_ASSERT(lowestPageNum > 0 && lowestPageNum <= m_numPages); QString num; for(int i = 0; i < m_numPagesListed; ++i) { QAbstractButton * button = m_buttonGroup->button(i); button->setText(num.setNum(lowestPageNum + i)); if(i == m_numPages) break; } }
QAbstractButton* newButton( const QString& text, QWidget* parent = 0 ) { QAbstractButton* pushButton = new QPushButton( parent ); pushButton->setText( text ); pushButton->setCheckable( true ); pushButton->setAutoExclusive( true ); pushButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ); pushButton->setAttribute( Qt::WA_LayoutUsesWidgetRect ); pushButton->setAttribute( Qt::WA_MacNoClickThrough ); return pushButton; }
logical OToolBox :: SetLabel (int32 indx0, QString qsText ) { logical term = NO; QAbstractButton *button = NULL; BEGINSEQ if(!(button=GetButton(indx0))) ERROR button->setText(qsText); RECOVER term = YES; ENDSEQ return(term); }
// ---------------------------------------------------------------------------- void ctkMessageBoxDontShowAgainTester::testDontShowAgainCustomText() { ctkMessageBox messageBox; messageBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); QAbstractButton *okButton = messageBox.button(QMessageBox::Ok); okButton->setText("SaveData"); QAbstractButton *cancelButton = messageBox.button(QMessageBox::Cancel); cancelButton->setText("Discard Data"); QFETCH(bool, visible); messageBox.setDontShowAgainVisible(visible); QFETCH(bool, dontShowAgain); messageBox.setDontShowAgain(dontShowAgain); this->testExecMessageBox(messageBox); // check that the don't show again text has been updated QCheckBox *checkBox = messageBox.findChild<QCheckBox*>("ctk_msgbox_dontshowcheckbox"); QString dontShowAgainText = checkBox->text(); if (visible) { // the custom text was set from the Ok box as it has the accept role QString expectedString = QString("Don't show this message again and always ") + okButton->text(); QCOMPARE(dontShowAgainText, expectedString); } else { // the custom text was not added to the end of the standard message QString expectedString = QString("Don't show this message again"); QCOMPARE(dontShowAgainText, expectedString); } }
void UIWizardNewVDPageBasic1::retranslateUi() { /* Translate page: */ setTitle(UIWizardNewVD::tr("Hard drive file type")); /* Translate widgets: */ m_pLabel->setText(UIWizardNewVD::tr("Please choose the type of file that you would like to use " "for the new virtual hard drive. If you do not need to use it " "with other virtualization software you can leave this setting unchanged.")); QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons(); for (int i = 0; i < buttons.size(); ++i) { QAbstractButton *pButton = buttons[i]; pButton->setText(VBoxGlobal::fullMediumFormatName(m_formatNames[m_pFormatButtonGroup->id(pButton)])); } }
CSVSettings::BooleanView::BooleanView (CSMSettings::Setting *setting, Page *parent) : View (setting, parent), mType(setting->type()) { foreach (const QString &value, setting->declaredValues()) { QAbstractButton *button = 0; switch (mType) { case CSMSettings::Type_CheckBox: { if(mButtons.empty()) // show only one for checkboxes { button = new QCheckBox (value, this); button->setChecked (setting->defaultValues().at(0) == "true" ? true : false); // special visual treatment option for checkboxes if(setting->specialValueText() != "") { Frame::setTitle(""); button->setText(setting->specialValueText()); } } } break; case CSMSettings::Type_RadioButton: button = new QRadioButton (value, this); break; default: break; } if(button && (mType != CSMSettings::Type_CheckBox || mButtons.empty())) { connect (button, SIGNAL (clicked (bool)), this, SLOT (slotToggled (bool))); button->setObjectName (value); addWidget (button); mButtons[value] = button; } }
int drv_basebutton(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9) { handle_head* head = (handle_head*)a0; QAbstractButton *self = (QAbstractButton*)head->native; switch (drvid) { case BASEBUTTON_SETTEXT: { self->setText(drvGetString(a1)); break; } case BASEBUTTON_TEXT: { drvSetString(a1,self->text()); break; } default: return 0; } return 1; }
void UIWizardCloneVDPageExpert::retranslateUi() { /* Translate widgets: */ m_pDestinationCnt->setTitle(UIWizardCloneVD::tr("&New disk image to create")); m_pDestinationDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a location for new virtual disk image file...")); m_pFormatCnt->setTitle(UIWizardCloneVD::tr("Disk image file &type")); QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons(); for (int i = 0; i < buttons.size(); ++i) { QAbstractButton *pButton = buttons[i]; UIMediumFormat enmFormat = gpConverter->fromInternalString<UIMediumFormat>(m_formatNames[m_pFormatButtonGroup->id(pButton)]); pButton->setText(gpConverter->toString(enmFormat)); } m_pVariantCnt->setTitle(UIWizardCloneVD::tr("Storage on physical hard disk")); m_pDynamicalButton->setText(UIWizardCloneVD::tr("&Dynamically allocated")); m_pFixedButton->setText(UIWizardCloneVD::tr("&Fixed size")); m_pSplitBox->setText(UIWizardCloneVD::tr("&Split into files of less than 2GB")); }
void UIWizardNewVDPageExpert::retranslateUi() { /* Translate widgets: */ m_pLocationCnt->setTitle(UIWizardNewVD::tr("File &location")); m_pLocationOpenButton->setToolTip(UIWizardNewVD::tr("Choose a location for new virtual hard disk file...")); m_pSizeCnt->setTitle(UIWizardNewVD::tr("File &size")); m_pFormatCnt->setTitle(UIWizardNewVD::tr("Hard disk file &type")); QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons(); for (int i = 0; i < buttons.size(); ++i) { QAbstractButton *pButton = buttons[i]; pButton->setText(VBoxGlobal::fullMediumFormatName(m_formatNames[m_pFormatButtonGroup->id(pButton)])); } m_pVariantCnt->setTitle(UIWizardNewVD::tr("Storage on physical hard disk")); m_pDynamicalButton->setText(UIWizardNewVD::tr("&Dynamically allocated")); m_pFixedButton->setText(UIWizardNewVD::tr("&Fixed size")); m_pSplitBox->setText(UIWizardNewVD::tr("&Split into files of less than 2GB")); }
void MusicPlayer::createWidgets() { playButton = new QToolButton(this); playButton->setEnabled(false); playButton->setToolTip(tr("Play")); playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); connect(playButton, SIGNAL(clicked()), this, SLOT(togglePlayback())); QAbstractButton *openButton = new QToolButton(this); openButton->setText(tr("...")); openButton->setToolTip(tr("Open a file...")); openButton->setFixedSize(playButton->sizeHint()); connect(openButton, SIGNAL(clicked()), this, SLOT(openFile())); volumeButton = new VolumeButton(this); volumeButton->setToolTip(tr("Adjust volume")); volumeButton->setVolume(mediaPlayer.volume()); connect(volumeButton, SIGNAL(volumeChanged(int)), &mediaPlayer, SLOT(setVolume(int))); positionSlider = new QSlider(Qt::Horizontal, this); positionSlider->setEnabled(false); positionSlider->setToolTip(tr("Seek")); connect(positionSlider, SIGNAL(valueChanged(int)), this, SLOT(setPosition(int))); infoLabel = new QLabel(this); positionLabel = new QLabel(tr("00:00"), this); positionLabel->setMinimumWidth(positionLabel->sizeHint().width()); QBoxLayout *controlLayout = new QHBoxLayout; controlLayout->setMargin(0); controlLayout->addWidget(openButton); controlLayout->addWidget(playButton); controlLayout->addWidget(positionSlider); controlLayout->addWidget(positionLabel); controlLayout->addWidget(volumeButton); QBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->addWidget(infoLabel); mainLayout->addLayout(controlLayout); }
DriverWidget::DriverWidget(const Device &device, QWidget *parent) : QWidget(parent) , ui(new Ui::Form) , m_radioGroup(new QButtonGroup(this)) { ui->setupUi(this); ui->label->setText(xi18nc("@info %1 is hardware vendor, %2 is hardware model", "<title>%1 %2</title>", device.vendor, device.model)); // We want to sort drivers so they have consistent order across starts. QList<Driver> driverList = device.drivers; qSort(driverList); foreach (const Driver &driver, driverList) { // This driver is not manual, but also has no package, hence we cannot // do anything with it and should not display anything. if (driver.package == nullptr && !driver.manualInstall){ qDebug() << "encountered invalid driver" << driver.package << driver.manualInstall << "for" << device.model; continue; } QAbstractButton *button; if (driverList.count() <= 1) { button = new QCheckBox(this); m_radioGroup->setExclusive(false); } else { button = new QRadioButton(this); } button->setProperty("package", driver.packageName); button->setProperty("builtin", driver.builtin); ui->verticalLayout->addWidget(button); m_radioGroup->addButton(button); if (driver.fuzzyActive) { button->setChecked(true); } if (driver.manualInstall) { button->setText(i18nc("Manually installed 3rd party driver", "This device is using a manually-installed driver : (%1)", driver.packageName)); break; // Manually installed drivers have no additional information available. } if (driver.recommended) { button->setText(i18nc("%1 is description and %2 is package name; when driver is recommended for use", "Using %1 from %2 (Recommended Driver)", driver.package->shortDescription(), driver.package->name())); } else { // !recommended button->setText(i18nc("%1 is description and %2 is package name", "Using %1 from %2", driver.package->shortDescription(), driver.package->name())); } if (driver.free) { button->setToolTip(i18nc("The driver is under a open source license", "Open Source Driver")); } else { // !free button->setToolTip(i18nc("The driver is under a proprietary license", "Proprietary Driver")); } } m_indexSelected = m_radioGroup->checkedId(); m_defaultSelection = m_indexSelected; connect(m_radioGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SIGNAL(selectionChanged())); }
RenameDialog::RenameDialog(FmFileInfo* src, FmFileInfo* dest, QWidget* parent, Qt::WindowFlags f): QDialog(parent, f), action_(ActionIgnore), applyToAll_(false) { ui = new Ui::RenameDialog(); ui->setupUi(this); FmPath* path = fm_file_info_get_path(dest); FmIcon* srcIcon = fm_file_info_get_icon(src); FmIcon* destIcon = fm_file_info_get_icon(dest); // show info for the source file QIcon icon = IconTheme::icon(srcIcon); QSize iconSize(fm_config->big_icon_size, fm_config->big_icon_size); QPixmap pixmap = icon.pixmap(iconSize); ui->srcIcon->setPixmap(pixmap); QString infoStr; const char* disp_size = fm_file_info_get_disp_size(src); if(disp_size) { infoStr = QString(tr("Type: %1\nSize: %2\nModified: %3")) .arg(QString::fromUtf8(fm_file_info_get_desc(src))) .arg(QString::fromUtf8(disp_size)) .arg(QString::fromUtf8(fm_file_info_get_disp_mtime(src))); } else { infoStr = QString(tr("Type: %1\nModified: %2")) .arg(QString::fromUtf8(fm_file_info_get_desc(src))) .arg(QString::fromUtf8(fm_file_info_get_disp_mtime(src))); } ui->srcInfo->setText(infoStr); // show info for the dest file icon = IconTheme::icon(destIcon); pixmap = icon.pixmap(iconSize); ui->destIcon->setPixmap(pixmap); disp_size = fm_file_info_get_disp_size(dest); if(disp_size) { infoStr = QString(tr("Type: %1\nSize: %2\nModified: %3")) .arg(QString::fromUtf8(fm_file_info_get_desc(dest))) .arg(QString::fromUtf8(disp_size)) .arg(QString::fromUtf8(fm_file_info_get_disp_mtime(dest))); } else { infoStr = QString(tr("Type: %1\nModified: %3")) .arg(QString::fromUtf8(fm_file_info_get_desc(src))) .arg(QString::fromUtf8(fm_file_info_get_disp_mtime(src))); } ui->destInfo->setText(infoStr); char* basename = fm_path_display_basename(path); ui->fileName->setText(QString::fromUtf8(basename)); oldName_ = basename; g_free(basename); connect(ui->fileName, SIGNAL(textChanged(QString)), SLOT(onFileNameChanged(QString))); // add "Rename" button QAbstractButton* button = ui->buttonBox->button(QDialogButtonBox::Ok); button->setText(tr("&Overwrite")); // FIXME: there seems to be no way to place the Rename button next to the overwrite one. renameButton_ = ui->buttonBox->addButton(tr("&Rename"), QDialogButtonBox::ActionRole); connect(renameButton_, SIGNAL(clicked(bool)), SLOT(onRenameClicked())); renameButton_->setEnabled(false); // disabled by default button = ui->buttonBox->button(QDialogButtonBox::Ignore); connect(button, SIGNAL(clicked(bool)), SLOT(onIgnoreClicked())); }
static void replaceButtonText(QWizard * wizard, QWizard::WizardButton which, const QString& text) { QAbstractButton * button = wizard->button(which); if (button != nullptr) button->setText(text); }
void measurepulse::on_pushButton_7_clicked() { publiccaution.addevent("摩擦系数测试页面","完成测试并退出","用户完成测试并退出",1); //校验上次的测试 QRegExp rx("^\\d+\\.?\\d*$"); if ( rx.indexIn(lineEdit[2]->text()) == -1) { QMessageBox msgBox; msgBox.setText("输入格式不对,请重新输入"); msgBox.setWindowTitle("输入错误"); msgBox.setStandardButtons(QMessageBox::Yes ); QAbstractButton* tb = msgBox.button(QMessageBox::Yes); tb->setText("确定"); return; } bool ok; if (lineEdit[2]->text().toDouble(&ok) == 0) { QMessageBox msgBox; msgBox.setText("输入数据为0,请重新输入"); msgBox.setWindowTitle("输入错误"); msgBox.setStandardButtons(QMessageBox::Yes ); QAbstractButton* tb = msgBox.button(QMessageBox::Yes); tb->setText("确定"); msgBox.exec(); return; } double count = 0; ksmc->GetEncoderCount(count); //新值小于小于旧值,说明可能翻转了 if (count < encoder[2]) { //真正翻转,而不是编码器回退,回退脉冲不可能超过3000000000 if (count < 1000000000 && encoder[2] > 4000000000) { encoder[2] = 4294967295 - encoder[2] + count; } else { encoder[2] = count - encoder[2]; } } else { encoder[2] = count - encoder[2]; } //校验编码计数 if (encoder[2] == 0) { QMessageBox msgBox; msgBox.setText("编码器计数没有变化,请重新测试"); msgBox.setWindowTitle("错误"); msgBox.setStandardButtons(QMessageBox::Yes ); QAbstractButton* tb = msgBox.button(QMessageBox::Yes); tb->setText("确定"); msgBox.exec(); ui.pushButton->setEnabled(false); ui.pushButton_2->setEnabled(false); ui.pushButton_3->setEnabled(false); ui.pushButton_4->setEnabled(false); ui.pushButton_5->setEnabled(true); ui.pushButton_6->setEnabled(false); ui.pushButton_7->setEnabled(false); lineEdit[0]->setEnabled(false); lineEdit[1]->setEnabled(false); lineEdit[2]->setEnabled(false); lineEdit[2]->clear(); //返回 return; } //3次的摩擦系数校验 //一致性标识 bool validcheck = true; meaure[0] = lineEdit[0]->text().toDouble(&ok); meaure[1] = lineEdit[1]->text().toDouble(&ok); meaure[2] = lineEdit[2]->text().toDouble(&ok); double frications[3]; for (int i = 0;i < 3; ++i) { if (meaure[i] != 0) { frications[i] = encoder[i] / meaure[i]; std::cout << "encoder,measure,frication:" << encoder[i] << "," << meaure[i] << "," << frications[i]; } else { frications[i] = 0; } } if((frications[0] - frications[1]) > 0) { if (((frications[0] - frications[1]) /frications[0]) > 0.005 ) { validcheck = false; } } else { if (((frications[1] - frications[0]) /frications[0]) > 0.005 ) { validcheck = false; } } if((frications[0] - frications[2]) > 0) { if (((frications[0] - frications[2]) /frications[0]) > 0.005 ) { validcheck = false; } } else { if (((frications[2] - frications[0]) /frications[0]) > 0.005 ) { validcheck = false; } } if((frications[2] - frications[1]) > 0) { if (((frications[2] - frications[1]) /frications[2]) > 0.005 ) { validcheck = false; } } else { if (((frications[1] - frications[2]) /frications[2]) > 0.005 ) { validcheck = false; } } if (validcheck == false) { QMessageBox msgBox; msgBox.setText("数据一致性不行,请重新测试"); msgBox.setWindowTitle("错误"); msgBox.setStandardButtons(QMessageBox::Yes ); QAbstractButton* tb = msgBox.button(QMessageBox::Yes); tb->setText("确定"); msgBox.exec(); ui.pushButton->setEnabled(true); ui.pushButton_2->setEnabled(false); ui.pushButton_3->setEnabled(false); ui.pushButton_4->setEnabled(false); ui.pushButton_5->setEnabled(false); ui.pushButton_6->setEnabled(false); ui.pushButton_7->setEnabled(false); lineEdit[0]->setEnabled(false); lineEdit[1]->setEnabled(false); lineEdit[2]->setEnabled(false); lineEdit[0]->clear(); lineEdit[1]->clear(); lineEdit[2]->clear(); return; } long frication = (long)(((frications[0] + frications[1] + frications[2])/3 ) * 1000) ; //摩擦系数范围检查 QDomNode paranode = GetParaByName("tune", "摩擦系数"); float minval,maxval; minval = paranode.firstChildElement("rangemin").text().toFloat(&ok); maxval = paranode.firstChildElement("rangemax").text().toFloat(&ok); //校验数据是否超标 if (frication > maxval || frication < minval) { QMessageBox msgBox; msgBox.setText("摩擦系数数据超出范围请重新测试!"); msgBox.setWindowTitle("错误"); msgBox.setStandardButtons(QMessageBox::Yes ); QAbstractButton* tb = msgBox.button(QMessageBox::Yes); tb->setText("确定"); msgBox.exec(); ui.pushButton->setEnabled(true); ui.pushButton_2->setEnabled(false); ui.pushButton_3->setEnabled(false); ui.pushButton_4->setEnabled(false); ui.pushButton_5->setEnabled(false); ui.pushButton_6->setEnabled(false); ui.pushButton_7->setEnabled(false); lineEdit[0]->setEnabled(false); lineEdit[1]->setEnabled(false); lineEdit[2]->setEnabled(false); lineEdit[0]->clear(); lineEdit[1]->clear(); lineEdit[2]->clear(); return; } //保存和应用 paranode.firstChildElement("value").firstChild().setNodeValue( QString::number(frication)); ksmc->SetPulserPerMeter(frication); //刷新到界面 FricationNodeItem->setText(QString::number(frication)); //保存XML文件 QFile file(QApplication::applicationDirPath() + QString("/aaa.xml")); if (!file.open(QFile::WriteOnly)) { QMessageBox msgBox; msgBox.setText("打开文件aaa.xml失败"); msgBox.setWindowTitle("错误"); msgBox.setStandardButtons(QMessageBox::Yes ); QAbstractButton* tb = msgBox.button(QMessageBox::Yes); tb->setText("确定"); msgBox.exec(); return; } QTextStream out(&file); doc->save(out, 4); //返回 this->accept(); }
void measurepulse::on_pushButton_5_clicked() { publiccaution.addevent("摩擦系数测试页面","第三次开始","用户第三次开始",1); //校验上次的测试 QRegExp rx("^\\d+\\.?\\d*$"); if ( rx.indexIn(lineEdit[1]->text()) == -1) { QMessageBox msgBox; msgBox.setText("输入格式不对,请重新输入"); msgBox.setWindowTitle("输入错误"); msgBox.setStandardButtons(QMessageBox::Yes ); QAbstractButton* tb = msgBox.button(QMessageBox::Yes); tb->setText("确定"); return; } bool ok; if (lineEdit[1]->text().toDouble(&ok) == 0) { QMessageBox msgBox; msgBox.setText("输入数据为0,请重新输入"); msgBox.setWindowTitle("输入错误"); msgBox.setStandardButtons(QMessageBox::Yes ); QAbstractButton* tb = msgBox.button(QMessageBox::Yes); tb->setText("确定"); msgBox.exec(); return; } //记录脉冲数 double count = 0; ksmc->GetEncoderCount(count); //新值小于小于旧值,说明可能翻转了 if (count < encoder[1]) { //真正翻转,而不是编码器回退,回退脉冲不可能超过3000000000 if (count < 1000000000 && encoder[1] > 4000000000) { encoder[1] = 4294967295 - encoder[1] + count; } else { encoder[1] = count - encoder[1]; } } else { encoder[1] = count - encoder[1]; } //校验编码计数 if (encoder[1] == 0) { QMessageBox msgBox; msgBox.setText("编码器计数没有变化,请重新测试"); msgBox.setWindowTitle("错误"); msgBox.setStandardButtons(QMessageBox::Yes ); QAbstractButton* tb = msgBox.button(QMessageBox::Yes); tb->setText("确定"); msgBox.exec(); ui.pushButton->setEnabled(false); ui.pushButton_2->setEnabled(true); ui.pushButton_3->setEnabled(true); ui.pushButton_4->setEnabled(true); ui.pushButton_5->setEnabled(false); ui.pushButton_6->setEnabled(true); ui.pushButton_7->setEnabled(false); lineEdit[0]->setEnabled(false); lineEdit[1]->setEnabled(false); lineEdit[2]->setEnabled(false); lineEdit[1]->clear(); //返回 return; } //记录脉冲数目 count = 0; ksmc->GetEncoderCount(count); encoder[2] = count; step = 3; interfaceevent* ptempevent = new interfaceevent(); ptempevent->cmd = 0x0a;//橡毯开始运动 ptempevent->status = 0x00;//命令状态 //发送一个事件给后台线程 QCoreApplication::postEvent(backendobject, ptempevent); //启动 ui.pushButton_5->setEnabled(false); lineEdit[1]->setEnabled(false); ui.pushButton_8->setEnabled(false); }
void Dialog::setButtonText(ButtonCode button, const QString &text) { QAbstractButton *b = getButton(button); if (b) { b->setText(text); } }
//打开串口设备 bool Open(struct serialif* pserialif) { pserialif->devmutex.lock(); //设置并打开端口 pserialif->hCom = CreateFileA(pserialif->Name.toAscii(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); if (pserialif->hCom == (HANDLE) - 1) { QMessageBox msgBox; msgBox.setText("没有检测到加密狗!"); msgBox.setWindowTitle("错误"); msgBox.setStandardButtons(QMessageBox::Yes ); QAbstractButton* tb = msgBox.button(QMessageBox::Yes); tb->setText("确定"); msgBox.exec(); } else { DCB wdcb; GetCommState(pserialif->hCom, &wdcb); wdcb.BaudRate = pserialif->BaudRate.toUInt(); wdcb.ByteSize = pserialif->ByteSize.toUInt(); if (pserialif->Parity == QString("EVEN")) { wdcb.Parity = EVENPARITY; } else if(pserialif->Parity == QString("ODD")) { wdcb.Parity = ODDPARITY; } else { wdcb.Parity = NOPARITY; } if (pserialif->StopBits == QString("2")) { wdcb.StopBits =TWOSTOPBITS; } else { wdcb.StopBits =ONESTOPBIT; } if (pserialif->fRtsControl == QString("disable")) { wdcb.fRtsControl = RTS_CONTROL_DISABLE; } else if(pserialif->fRtsControl == QString("handshake")) { wdcb.fRtsControl = RTS_CONTROL_HANDSHAKE; } else if(pserialif->fRtsControl == QString("toggle")) { wdcb.fRtsControl = RTS_CONTROL_TOGGLE; } else { wdcb.fRtsControl = RTS_CONTROL_ENABLE; } SetCommState(pserialif->hCom, &wdcb); PurgeComm(pserialif->hCom, PURGE_TXCLEAR|PURGE_RXCLEAR); //异步要设置超时时间 COMMTIMEOUTS m_timeout; m_timeout.ReadIntervalTimeout = 1000; m_timeout.ReadTotalTimeoutConstant = 1000; m_timeout.ReadTotalTimeoutMultiplier = 1000; m_timeout.WriteTotalTimeoutConstant = 1000; m_timeout.WriteTotalTimeoutMultiplier =1000; SetCommTimeouts(pserialif->hCom,&m_timeout); pserialif->deviceopen = true; } pserialif->devmutex.unlock(); return true; }