本文整理汇总了C++中ToolButton::setChecked方法的典型用法代码示例。如果您正苦于以下问题:C++ ToolButton::setChecked方法的具体用法?C++ ToolButton::setChecked怎么用?C++ ToolButton::setChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToolButton
的用法示例。
在下文中一共展示了ToolButton::setChecked方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initRectLabel
void SubToolBar::initRectLabel() {
m_rectLabel = new QLabel(this);
QButtonGroup* rectBtnGroup = new QButtonGroup();
rectBtnGroup->setExclusive(true);
QList<ToolButton*> btnList;
//rectangle, oval...
ToolButton* fineLine = new ToolButton();
fineLine->setObjectName("FineLine");
rectBtnGroup->addButton(fineLine);
btnList.append(fineLine);
ToolButton* mediumLine = new ToolButton();
mediumLine->setObjectName("MediumLine");
rectBtnGroup->addButton(mediumLine);
btnList.append(mediumLine);
ToolButton* thickLine = new ToolButton();
thickLine->setObjectName("ThickLine");
rectBtnGroup->addButton(thickLine);
btnList.append(thickLine);
//separator line...
QLabel* vSeparatorLine = new QLabel();
vSeparatorLine->setFixedSize(1, 16);
vSeparatorLine->setObjectName("VerticalSeparatorLine");
//blur, mosaic...
ToolButton* blurBtn = new ToolButton();
blurBtn->setObjectName("BlurBtn");
ToolButton* mosaicBtn = new ToolButton();
mosaicBtn->setObjectName("MosaicBtn");
connect(blurBtn, &ToolButton::clicked, this, [=]{
ConfigSettings::instance()->setValue("effect", "is_blur", blurBtn->isChecked());
if (blurBtn->isChecked()) {
mosaicBtn->setChecked(false);
ConfigSettings::instance()->setValue("effect", "is_mosaic", false);
}
});
connect(mosaicBtn, &ToolButton::clicked, this, [=]{
ConfigSettings::instance()->setValue("effect", "is_mosaic", mosaicBtn->isChecked());
if (mosaicBtn->isChecked()) {
blurBtn->setChecked(false);
ConfigSettings::instance()->setValue("effect", "is_blur", false);
}
});
int lineWidthIndex = ConfigSettings::instance()->value("rectangle",
"linewidth_index").toInt();
btnList[lineWidthIndex]->setChecked(true);
QHBoxLayout* rectLayout = new QHBoxLayout();
rectLayout->setMargin(0);
rectLayout->setSpacing(0);
rectLayout->addSpacing(1);
for (int i = 0; i < btnList.length(); i++) {
rectLayout->addWidget(btnList[i]);
rectLayout->addSpacing(BUTTON_SPACING);
connect(btnList[i], &ToolButton::clicked, this, [=]{
ConfigSettings::instance()->setValue(m_currentType, "linewidth_index", i);
});
}
rectLayout->addSpacing(16);
rectLayout->addWidget(vSeparatorLine);
rectLayout->addSpacing(16);
rectLayout->addWidget(blurBtn);
rectLayout->addSpacing(BUTTON_SPACING);
rectLayout->addWidget(mosaicBtn);
rectLayout->addStretch();
m_rectLabel->setLayout(rectLayout);
addWidget(m_rectLabel);
connect(this, &SubToolBar::shapeChanged, this, [=]{
int lineIndex = ConfigSettings::instance()->value(m_currentType,
"linewidth_index").toInt();
btnList[lineIndex]->setChecked(true);
});
}
示例2: initArrowLabel
void SubToolBar::initArrowLabel() {
m_arrowLabel = new QLabel(this);
//arrow
QButtonGroup* arrowBtnGroup = new QButtonGroup();
arrowBtnGroup->setExclusive(true);
QList<ToolButton*> arrowBtnList;
ToolButton* arrowFineLine = new ToolButton();
arrowFineLine->setObjectName("ArrowFine");
arrowBtnGroup->addButton(arrowFineLine);
arrowBtnList.append(arrowFineLine);
ToolButton* arrowMediumLine = new ToolButton();
arrowMediumLine->setObjectName("ArrowMedium");
arrowBtnGroup->addButton(arrowMediumLine);
arrowBtnList.append(arrowMediumLine);
ToolButton* arrowThickLine = new ToolButton();
arrowThickLine->setObjectName("ArrowThick");
arrowBtnGroup->addButton(arrowThickLine);
arrowBtnList.append(arrowThickLine);
//line
QButtonGroup* lineBtnGroup = new QButtonGroup();
lineBtnGroup->setExclusive(true);
//rectangle, oval...
ToolButton* fineLine = new ToolButton();
fineLine->setObjectName("ArrowFineLine");
lineBtnGroup->addButton(fineLine);
arrowBtnList.append(fineLine);
ToolButton* mediumLine = new ToolButton();
mediumLine->setObjectName("ArrowMediumLine");
lineBtnGroup->addButton(mediumLine);
arrowBtnList.append(mediumLine);
ToolButton* thickLine = new ToolButton();
thickLine->setObjectName("ArrowThickLine");
lineBtnGroup->addButton(thickLine);
arrowBtnList.append(thickLine);
//separator line...
QLabel* vSeparatorLine = new QLabel();
vSeparatorLine->setFixedSize(1, 16);
vSeparatorLine->setObjectName("VerticalSeparatorLine");
QButtonGroup* styleBtnGroup = new QButtonGroup;
styleBtnGroup->setExclusive(true);
ToolButton* lineBtn = new ToolButton();
lineBtn->setObjectName("LineBtn");
styleBtnGroup->addButton(lineBtn, 0);
ToolButton* arrowBtn = new ToolButton();
arrowBtn->setObjectName("ArrowBtn");
arrowBtn->setChecked(true);
styleBtnGroup->addButton(arrowBtn, 1);
if (ConfigSettings::instance()->value("arrow", "is_straight").toBool()) {
lineBtn->setChecked(true);
} else {
arrowBtn->setChecked(true);
}
int arrowWidthIndex = ConfigSettings::instance()->value("arrow", "arrow_linewidth_index").toInt();
int sLineWidthIndex = ConfigSettings::instance()->value("arrow", "straightline_linewidth").toInt();
arrowBtnList[arrowWidthIndex]->setChecked(true);
arrowBtnList[sLineWidthIndex+3]->setChecked(true);
QHBoxLayout* arrowLayout = new QHBoxLayout();
arrowLayout->setMargin(0);
arrowLayout->setSpacing(BUTTON_SPACING);
arrowLayout->addSpacing(1);
for (int j = 0; j < arrowBtnList.length(); j++) {
arrowLayout->addWidget(arrowBtnList[j]);
// arrowLayout->addSpacing(BUTTON_SPACING);
connect(arrowBtnList[j], &ToolButton::clicked, this, [=]{
if (j < 3) {
ConfigSettings::instance()->setValue("arrow", "arrow_linewidth_index", j);
} else {
ConfigSettings::instance()->setValue("arrow", "straightline_linewidth_index", j - 3);
}
});
}
arrowLayout->addSpacing(16);
arrowLayout->addWidget(vSeparatorLine);
arrowLayout->addSpacing(16);
arrowLayout->addWidget(lineBtn);
arrowLayout->addWidget(arrowBtn);
arrowLayout->addStretch();
m_arrowLabel->setLayout(arrowLayout);
addWidget(m_arrowLabel);
fineLine->hide();
mediumLine->hide();
thickLine->hide();
connect(arrowBtn, &ToolButton::toggled, this, [=](bool checked){
if (checked) {
arrowFineLine->show();
arrowMediumLine->show();
arrowThickLine->show();
fineLine->hide();
mediumLine->hide();
thickLine->hide();
} else {
arrowFineLine->hide();
arrowMediumLine->hide();
arrowThickLine->hide();
fineLine->show();
mediumLine->show();
thickLine->show();
//.........这里部分代码省略.........