本文整理汇总了C++中QAbstractButton::setPalette方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractButton::setPalette方法的具体用法?C++ QAbstractButton::setPalette怎么用?C++ QAbstractButton::setPalette使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractButton
的用法示例。
在下文中一共展示了QAbstractButton::setPalette方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: changeProgressBarColor
void RazorSensorsConfiguration::changeProgressBarColor()
{
QAbstractButton* btn = qobject_cast<QAbstractButton*>(sender());
if (btn)
{
QPalette pal = btn->palette();
QColor color = QColorDialog::getColor(pal.color(QPalette::Normal, QPalette::Button), this);
if (color.isValid())
{
pal.setColor(QPalette::Normal, QPalette::Button, color);
btn->setPalette(pal);
saveSettings();
}
}
else
{
qDebug() << "RazorSensorsConfiguration::changeProgressBarColor():" << "invalid button cast";
}
}
示例2: 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);
}
}
};
示例3: slotStateVariables
void ClsQNeuronStateVariableDisplay::slotStateVariables(int ii){
#ifdef DEBUG_CLSQSTATEVARIABLEDISPLAY
cout << "void ClsQNeuronStateVariableDisplay::slotStateVariables(int ii)" << endl;
#endif
/*
cout << "qbtngrpStateVariables->exclusive ( ): " << qbtngrpStateVariables->exclusive ( ) << endl;
cout << "iCurrentStateButton: " << iCurrentStateButton << endl;
cout << "ii: " << ii << endl;
*/
QAbstractButton *btn = qbtngrpStateVariables->button ( ii );
if(btn==NULL){
return;
}
if(qchkbxLiveData->isOn() && ii != iCurrentStateButton){
if(btn->isChecked()){
//cout << "send request: " << btn->text().latin1() << endl;
/* send request */
string strSinkID = btn->text().latin1() + strID;
clsFEDataClient->addDataSink(strSinkID, clsFEGroup, btn->text().latin1(), strSelectedIndices);
QColor qc;
qc.setHsv(clsFEDataClient->getDataSinkColor(strSinkID), 255, 210);
QPalette palette = (btn)->palette();
palette.setColor ( QColorGroup::Foreground, qc );
(btn)->setPalette(palette);
if(bAverage){
clsFEDataClient->setSinkMath(strSinkID, ClsFEDataSink::MATH_AVERAGE);
}
if(qbtngrpStateVariables->exclusive( ) && iCurrentStateButton >= 0){
/* cancel rewquest of the last active checkbox (iCurrentStateButton) */
QAbstractButton *btnCurrent = qbtngrpStateVariables->button (iCurrentStateButton);
if(btnCurrent!=NULL){
// cout << "cancel request: " << btnCurrent->text().latin1() << endl;
string strSinkID = btnCurrent->text().latin1() + strID;
clsFEDataClient->removeDataSink(strSinkID);
QColor qc;
qc.setRgb(0,0,0);
QPalette palette = btnCurrent->palette();
palette.setColor ( QColorGroup::Foreground, qc );
btnCurrent->setPalette(palette);
}
}
} else {
/* cancel request */
// cout << "cancel request: " << btn->text().latin1() << endl;
string strSinkID = btn->text().latin1() + strID;
clsFEDataClient->removeDataSink(strSinkID);
QColor qc;
qc.setRgb(0,0,0);
QPalette palette = (btn)->palette();
palette.setColor ( QColorGroup::Foreground, qc );
(btn)->setPalette(palette);
}
}
if(qbtngrpStateVariables->exclusive ( )){
iCurrentStateButton = ii;
}
};