void SpinBox::initStyleOption(QStyleOptionSpinBox& so) const { so.init(this); // so.activeSubControls = ??; so.subControls = mUpDownOnly ? QStyle::SC_SpinBoxUp | QStyle::SC_SpinBoxDown | QStyle::SC_SpinBoxFrame : QStyle::SC_SpinBoxUp | QStyle::SC_SpinBoxDown | QStyle::SC_SpinBoxFrame | QStyle::SC_SpinBoxEditField; so.buttonSymbols = buttonSymbols(); so.frame = hasFrame(); so.stepEnabled = stepEnabled(); }
void ATCMspinbox::paintEvent(QPaintEvent * e) { Q_UNUSED( e ); QPainter painter(this); QPalette palette = this->palette(); QStyleOptionSpinBox opt; opt.init(this); /* font color */ palette.setColor(QPalette::Text,m_fontcolor); /* label color */ palette.setColor(QPalette::ButtonText,m_labelcolor); /* border color */ palette.setColor(QPalette::Foreground, m_bordercolor); /* bg color */ palette.setColor(QPalette::Button, m_bgcolor); if (m_apparence == QFrame::Raised) { opt.state = QStyle::State_Raised; } else if (m_apparence == QFrame::Sunken) { opt.state = QStyle::State_Sunken; } #ifdef TARGET_ARM if (m_viewstatus) { /* draw the background color in funtion of the status */ palette.setColor(QPalette::Foreground, Qt::red); if (m_status & STATUS_OK) palette.setColor(QPalette::Foreground, Qt::green); else if (m_status & (STATUS_BUSY_R | STATUS_BUSY_W)) palette.setColor(QPalette::Foreground, Qt::yellow); else if (m_status & (STATUS_FAIL_W | STATUS_ERR)) palette.setColor(QPalette::Foreground, Qt::red); else palette.setColor(QPalette::Foreground, Qt::gray); } #endif opt.palette = palette; _diameter_ = m_borderradius; _penWidth_ = m_borderwidth; style()->drawComplexControl(QStyle::CC_SpinBox, &opt, &painter, this); }
static QStyleOptionSpinBox getStyleOption(const Q3SpinWidget *spin) { QStyleOptionSpinBox opt; opt.init(spin); opt.frame = true; opt.subControls = 0; opt.buttonSymbols = (QAbstractSpinBox::ButtonSymbols)spin->buttonSymbols(); opt.stepEnabled = 0; if (spin->isUpEnabled()) opt.stepEnabled |= QAbstractSpinBox::StepUpEnabled; if (spin->isDownEnabled()) opt.stepEnabled |= QAbstractSpinBox::StepDownEnabled; opt.activeSubControls = 0; return opt; }