本文整理汇总了C++中QAbstractButton::toggle方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractButton::toggle方法的具体用法?C++ QAbstractButton::toggle怎么用?C++ QAbstractButton::toggle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractButton
的用法示例。
在下文中一共展示了QAbstractButton::toggle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
//! [1]
Counter a, b;
//! [1] //! [2]
QObject::connect(&a, SIGNAL(valueChanged(int)),
&b, SLOT(setValue(int)));
//! [2]
//! [3]
a.setValue(12); // a.value() == 12, b.value() == 12
//! [3] //! [4]
b.setValue(48); // a.value() == 12, b.value() == 48
//! [4]
QWidget *widget = reinterpret_cast<QWidget *>(new QObject(0));
//! [5]
if (widget->inherits("QAbstractButton")) {
QAbstractButton *button = static_cast<QAbstractButton *>(widget);
button->toggle();
//! [5] //! [6]
}
//! [6]
//! [7]
if (QAbstractButton *button = qobject_cast<QAbstractButton *>(widget))
button->toggle();
//! [7]
}
示例2: coordBoxClicked
/*!
When one of the 6 coordinate check boxes is clicked, this checks to see
how many are already selected. It only allows a box to be checked if there
are fewer than 3 boxes already checked. If there are 3 checked, the OK
button is enabled, otherwise it is disabled. \a whichFixed keeps track of
the indexes of the currently selected check boxes.
*/
void GWSProjDlg::coordBoxClicked(int buttonNum)
{
QAbstractButton *b = coordButtonGroup->button(buttonNum);
if (b->isChecked()) {
if (whichFixed.size() < 3) {
whichFixed.insert(buttonNum);
if (whichFixed.size() == 3) { OKButton->setEnabled(true); }
}
else {
b->toggle();
}
}
else {
whichFixed.erase(buttonNum);
OKButton->setEnabled(false);
}
}
示例3: setSelectedStates
void ClsQNeuronStateVariableDisplay::setSelectedStates(list<string> lstStates) {
#ifdef DEBUG_CLSQSTATEVARIABLEDISPLAY
cout << "ClsQNeuronStateVariableDisplay::setSelectedStates(list<string> lst)" << endl;
#endif
QList<QAbstractButton *> lst = qbtngrpStateVariables->buttons ();
QList<QAbstractButton*>::iterator it;
for (it = lst.begin(); it != lst.end(); ++it) {
string str= (string)((*it)->text().latin1());
if(std::find(lstStates.begin(), lstStates.end(), str) != lstStates.end()){
QAbstractButton *qrb = (*it);
qrb->toggle();
string strSinkID = qrb->text().latin1() + strID;
QColor qc;
qc.setHsv(clsFEDataClient->getDataSinkColor(strSinkID), 255, 210);
QPalette palette = qrb->palette();
palette.setColor ( QColorGroup::Foreground, qc );
// palette.setColor ( QColorGroup::ButtonText, qc );
qrb->setPalette(palette);
}
}
};