本文整理汇总了C++中QCheckBox::checkState方法的典型用法代码示例。如果您正苦于以下问题:C++ QCheckBox::checkState方法的具体用法?C++ QCheckBox::checkState怎么用?C++ QCheckBox::checkState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCheckBox
的用法示例。
在下文中一共展示了QCheckBox::checkState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_toolButton_print_clicked
void PringKvitok::on_toolButton_print_clicked()
{
#if !defined(QT_NO_PRINTER)
QPrinter printer(QPrinter::HighResolution);
QPrintDialog *dlg = new QPrintDialog(&printer, this);
dlg->setWindowTitle(tr("Настройки принтера"));
if (dlg->exec() == QDialog::Accepted){
QString pg;
QMapIterator<QString, QCheckBox*> i(childsCheckBox_map);
ui->progressBar->setVisible(true);
int count = 0;
int c = 0;
while (i.hasNext()) {
i.next();
QCheckBox *cb = i.value();
if (cb->checkState() == Qt::Checked){
count++;
}
}
ui->progressBar->setMaximum(count);
QString page1;
QString page2;
while (i.hasPrevious()) {
i.previous();
QCheckBox *cb = i.value();
if (cb->checkState() == Qt::Checked){
if (ui->checkBox_twokv->checkState() == Qt::Checked){
if (page1 == "") page1 = prepareKvit(cb->text());
else {
page2 = prepareKvit(cb->text());
pg += TwoKvitOnePage(page1, page2);
page1 = "";
page2 = "";
}
} else pg += prepareKvit(cb->text());
ui->progressBar->setValue(c++);
}
}
if (ui->checkBox_twokv->checkState() == Qt::Checked && page1 != "" && page2 == "") pg += page1;
QTextDocument textDocument;
textDocument.setHtml(pg);
QPrinter printer(QPrinter::HighResolution);
printer.setOrientation(QPrinter::Portrait);
printer.setPaperName("A4");
printer.setPageMargins(0.3, 0.3, 0.3, 0.3, QPrinter::Unit() );
if (ui->checkBox_duplex->checkState() == Qt::Checked)printer.setDuplex(QPrinter::DuplexAuto);
textDocument.print(&printer);
ui->progressBar->setVisible(false);
}
delete dlg;
#endif
}
示例2: on_toolButton_pdf_clicked
void PringKvitok::on_toolButton_pdf_clicked()
{
#if !defined(QT_NO_PRINTER)
QString pg;
QMapIterator<QString, QCheckBox*> i(childsCheckBox_map);
ui->progressBar->setVisible(true);
int count = 0;
int c = 0;
while (i.hasNext()) {
i.next();
QCheckBox *cb = i.value();
if (cb->checkState() == Qt::Checked){
count++;
}
}
ui->progressBar->setMaximum(count);
QString page1;
QString page2;
while (i.hasPrevious()) {
i.previous();
QCheckBox *cb = i.value();
if (cb->checkState() == Qt::Checked){
if (ui->checkBox_twokv->checkState() == Qt::Checked){
if (page1 == "") page1 = prepareKvit(cb->text());
else {
page2 = prepareKvit(cb->text());
pg += TwoKvitOnePage(page1, page2);
page1 = "";
page2 = "";
}
} else pg += prepareKvit(cb->text());
ui->progressBar->setValue(c++);
}
}
if (ui->checkBox_twokv->checkState() == Qt::Checked && page1 != "" && page2 == "") pg += page1;
QTextDocument textDocument;
textDocument.setHtml(pg);
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName( "print.pdf");
printer.setOrientation(QPrinter::Portrait);
printer.setPaperName("A4");
printer.setPageMargins(1, 1, 1, 1, QPrinter::Millimeter );
textDocument.print(&printer);
ui->progressBar->setValue(c++);
ui->progressBar->setVisible(false);
#endif
}
示例3: GetBool
bool ParamWidget::GetBool(const QString& name) {
QCheckBox* checkbox = dynamic_cast<QCheckBox*>(GetWidget(name));
if (!checkbox) {
throw std::invalid_argument("Invalid bool parameter " + name.toStdString());
}
return checkbox->checkState() == Qt::Checked;
}
示例4: drv_checkbox
int drv_checkbox(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;
QCheckBox *self = (QCheckBox*)head->native;
switch (drvid) {
case CHECKBOX_INIT: {
drvNewObj(a0,new QCheckBox);
break;
}
case CHECKBOX_SETCHECK: {
self->setCheckState((Qt::CheckState)drvGetInt(a1));
break;
}
case CHECKBOX_CHECK: {
drvSetInt(a1,self->checkState());
break;
}
case CHECKBOX_SETTRISTATE: {
self->setTristate(drvGetBool(a1));
break;
}
case CHECKBOX_ISTRISTATE: {
drvSetBool(a1,self->isTristate());
break;
}
case CHECKBOX_ONSTATECHANGED: {
QObject::connect(self,SIGNAL(stateChanged(int)),drvNewSignal(self,a1,a2),SLOT(call(int)));
break;
}
default:
return 0;
}
return 1;
}
示例5: actionText
/*! \reimp */
QString QAccessibleButton::actionText(int action, Text text, int child) const
{
if (child)
return QString();
if (text == Name) switch (action) {
case Press:
case DefaultAction: // press, checking or open
switch (role(0)) {
case ButtonMenu:
return QPushButton::tr("Open");
case CheckBox:
{
if (state(child) & Checked)
return QCheckBox::tr("Uncheck");
QCheckBox *cb = qobject_cast<QCheckBox*>(object());
if (!cb || !cb->isTristate() || cb->checkState() == Qt::PartiallyChecked)
return QCheckBox::tr("Check");
return QCheckBox::tr("Toggle");
}
break;
case RadioButton:
return QRadioButton::tr("Check");
default:
break;
}
break;
}
return QAccessibleWidgetEx::actionText(action, text, child);
}
示例6: myPulseDevice
/**
* Return checked Pulse Device
*/
const QString QvkPulse::myPulseDevice( QVBoxLayout *Pulseframe )
{
QList<QCheckBox *> listQFrame = Pulseframe->findChildren<QCheckBox *>();
QCheckBox *box;
QList<int> integerList;
QString ret;
for ( int i = 0; i < listQFrame.count(); i++ )
{
box = listQFrame.at( i );
if ( box->checkState() == Qt::Checked )
integerList.append( i );
}
if ( integerList.count() == 0 )
ret = "";
if ( integerList.count() == 1 )
{
box = listQFrame[ integerList[ 0 ] ];
ret = box->accessibleName();
}
if ( integerList.count() > 1 )
ret = "vokoscreenMix.monitor";
return ret;
}
示例7: state
QAccessible::State QAccessibleButton::state() const
{
QAccessible::State state = QAccessibleWidget::state();
QAbstractButton *b = button();
QCheckBox *cb = qobject_cast<QCheckBox *>(b);
if (b->isCheckable())
state.checkable = true;
if (b->isChecked())
state.checked = true;
else if (cb && cb->checkState() == Qt::PartiallyChecked)
state.checkStateMixed = true;
if (b->isDown())
state.pressed = true;
QPushButton *pb = qobject_cast<QPushButton*>(b);
if (pb) {
if (pb->isDefault())
state.defaultButton = true;
#ifndef QT_NO_MENU
if (pb->menu())
state.hasPopup = true;
#endif
}
return state;
}
示例8:
void
pcl::modeler::BoolParameter::getEditorData(QWidget *editor)
{
QCheckBox *checkBox = static_cast<QCheckBox*>(editor);
bool value = (checkBox->checkState() == Qt::Checked);
current_value_ = value;
}
示例9: HandleUpdateInvisibleChanged
void EmitterAttributeEditor::HandleUpdateInvisibleChanged(int value)
{
if(updatingWidget_)
return;
QCheckBox* chk = (QCheckBox*)sender();
GetEffect()->SetUpdateInvisible(chk->checkState() == Qt::Checked);
}
示例10: setModelData
void PropertyEditDelegate::setModelData(QWidget* editor_,
QAbstractItemModel* model_,
const QModelIndex& index) const
{
const QVariant& data = index.data();
GeneratorPropertiesModel* model =
static_cast<GeneratorPropertiesModel*>(model_);
switch (data.type())
{
case QVariant::Double:
{
QLineEdit* editor = static_cast<QLineEdit*>(editor_);
model->setData(index, editor->text().toDouble(), Qt::EditRole);
break;
}
case QVariant::Int:
{
QSpinBox* editor = static_cast<QSpinBox*>(editor_);
editor->interpretText();
model->setData(index, editor->value(), Qt::EditRole);
break;
}
case QVariant::Bool:
{
QCheckBox* editor = static_cast<QCheckBox*>(editor_);
const bool value = editor->checkState() == Qt::Checked;
model->setData(index, value, Qt::EditRole);
break;
}
case QVariant::List:
{
QLineEdit* editor = static_cast<QLineEdit*>(editor_);
QStringList list = editor->text().split(",");
QVariantList varList;
QDoubleValidator validator;
for (QString& str : list)
{
if (str == "")
continue;
int pos = 0;
if (validator.validate(str, pos) == QValidator::Acceptable)
varList.push_back(QVariant(str.toDouble()));
else
varList.push_back(QVariant(-1.0));
}
model->setData(index, varList, Qt::EditRole);
break;
}
default:
{
break;
}
}
}
示例11: updateTreeChecks
void GUIImport::updateTreeChecks(QObject* obj)
{
QTreeWidgetItem* sender = (QTreeWidgetItem*)obj;
QCheckBox* check = (QCheckBox*)ui->viewTree->itemWidget(sender, COL_CHECKBOX);
if (!sender->parent())
{
Qt::CheckState state = check->checkState();
if (check->checkState() == Qt::PartiallyChecked)
state = Qt::Unchecked;
// just disable or enable childs
for (int i = 0; i < sender->childCount(); i++)
{
QTreeWidgetItem* attrItem = sender->child(i);
QCheckBox* attr_check = (QCheckBox*)ui->viewTree->itemWidget(attrItem, COL_CHECKBOX);
attr_check->setCheckState(state);
}
}
else
{
// clicking on child, check state of siblings
int numChecked = 0;
int numChilds = sender->parent()->childCount();
if (numChilds > 0)
{
for (int i = 0; i < numChilds; i++)
{
QCheckBox* attr_check = (QCheckBox*)ui->viewTree->itemWidget(sender->parent()->child(i), COL_CHECKBOX);
if (attr_check->checkState() == Qt::Checked)
numChecked++;
}
QCheckBox* view_check = (QCheckBox*)ui->viewTree->itemWidget(sender->parent(), COL_CHECKBOX);
if (numChecked == numChilds)
view_check->setCheckState(Qt::Checked);
else
view_check->setCheckState(Qt::PartiallyChecked);
}
}
}
示例12: createAdvancedTab
QWidget* EditIndexDialog::createAdvancedTab()
{
QWidget *advanced = new QWidget(this);
_sparceCheckBox = new QCheckBox(tr("Sparse"), advanced);
_sparceCheckBox->setChecked(_info._sparse);
_backGroundCheckBox = new QCheckBox(tr("Create index in background"), advanced);
_backGroundCheckBox->setChecked(_info._backGround);
QHBoxLayout *expireLayout = new QHBoxLayout;
_expireAfterLineEdit = new QLineEdit(advanced);
_expireAfterLineEdit->setMaximumWidth(150);
QRegExp rx("\\d+");
_expireAfterLineEdit->setValidator(new QRegExpValidator(rx, this));
QLabel *secLabel = new QLabel(tr("seconds"), advanced);
expireLayout->addWidget(_expireAfterLineEdit);
expireLayout->addWidget(secLabel);
expireLayout->addStretch(1);
QCheckBox *expireCheckBox = new QCheckBox(tr("Expire after"));
expireCheckBox->setChecked(false);
if (_info._ttl >= 0) {
expireCheckBox->setChecked(true);
_expireAfterLineEdit->setText(QString("%1").arg(_info._ttl));
}
expireStateChanged(expireCheckBox->checkState());
VERIFY(connect(expireCheckBox, SIGNAL(stateChanged(int)), this, SLOT(expireStateChanged(int))));
QLabel *sparseHelpLabel = createHelpLabel(
"If set, the index only references documents with the specified field. "
"These indexes use less space but behave differently in some situations (particularly sorts).",
20, -2, 0, 20);
QLabel *backgroundHelpLabel = createHelpLabel(
"Builds the index in the background so that building an index does not block other database activities.",
20, -2, 0, 20);
QLabel *expireHelpLabel = createHelpLabel(
"Specifies a <i>time to live</i>, in seconds, to control how long MongoDB retains documents in this collection",
20, -2, 0, 20);
QGridLayout *layout = new QGridLayout;
layout->addWidget(_sparceCheckBox, 0, 0, 1, 2);
layout->addWidget(sparseHelpLabel, 1, 0, 1, 2);
layout->addWidget(_backGroundCheckBox, 2, 0, 1, 2);
layout->addWidget(backgroundHelpLabel, 3, 0, 1, 2);
layout->addWidget(expireCheckBox, 4, 0);
layout->addLayout(expireLayout, 4, 1);
layout->addWidget(expireHelpLabel, 5, 0, 1, 2);
layout->setAlignment(Qt::AlignTop);
advanced->setLayout(layout);
return advanced;
}
示例13: flushCache
void ConfigPage::flushCache()
{
// sync the cache with the widgets' state
// iterate on checkboxes
for (std::map<QString, WidgetCache<bool> >::iterator it = checkboxCache.begin(); it != checkboxCache.end(); it++)
{
QCheckBox* checkbox = dynamic_cast<QCheckBox*>((it->second).widget);
Q_ASSERT(checkbox);
(it->second).value = CHECKED_TO_BOOL(checkbox->checkState());
}
}
示例14: GetValue
QVariant ItemHandlerCheckbox::GetValue (QObject *object) const
{
QCheckBox *checkbox = qobject_cast<QCheckBox*> (object);
if (!checkbox)
{
qWarning () << Q_FUNC_INFO
<< "not a QCheckBox"
<< object;
return QVariant ();
}
return checkbox->checkState ();
}
示例15: sender
void
Application::actuallyQuit()
{
QDialog* d = qobject_cast<QDialog*>( sender());
if( d ) {
QCheckBox* dontAskCB = d->findChild<QCheckBox*>();
if( dontAskCB ) {
unicorn::AppSettings().setValue( "quitDontAsk", ( dontAskCB->checkState() == Qt::Checked ));
}
}
QCoreApplication::quit();
}