void YbToolButton::setChecked(bool isChecked) { if(isEnabled()){ if(m_isCheckable){ m_isChecked = isChecked; if(m_isChecked){ setBkPalette(224, 238, 238); }else{ setBkPalette(255, 255, 255, 0); } } } }
void myPushButton::mousePressEvent(QMouseEvent *e) { //setBkPalette(150); QPixmap pixmap(iconStatus.at(2)); setBkPalette(0.5); setIcon(QIcon(pixmap)); }
void myPushButton::enterEvent(QEvent *) { //setBkPalette(120); QPixmap pixmap(iconStatus.at(1)); setBkPalette(0.5); setIcon(QIcon(pixmap)); }
void YbToolButton::enterEvent(QEvent *e) { (void)e; if(m_isCheckable){ if(isEnabled() && !m_isChecked){ setBkPalette(224, 238, 238); } }else{ if(isEnabled()){ } } }
myPushButton::myPushButton(QStringList iconStr, QWidget *parent):QPushButton(parent) { iconStatus = iconStr; if(iconStatus.count() >= 2) { QPixmap pixmap(iconStatus.at(0)); setIcon(QIcon(pixmap)); setIconSize(pixmap.size()); resize(pixmap.size()); setBkPalette(0);//设置背景完全透明 setFlat(true); setAutoFillBackground(true); } }
void YbToolButton::mouseReleaseEvent(QMouseEvent *e) { if(this->rect().contains(e->pos())){ if(m_isCheckable){ if(isEnabled() && !m_isChecked){ m_isChecked = true; setBkPalette(224, 238, 238); } }else{ if(isEnabled()){ } } emit toolClicked(); } }
void YbToolButton::mousePressEvent(QMouseEvent *e) { (void)e; if(m_isCheckable){ if(isEnabled() && !m_isChecked){ setBkPalette(224, 238, 238); m_textLabel->setFont(boldFont); m_picLabel->clear(); m_picLabel->setPixmap(m_checkedPixmap); m_picLabel->setFixedSize(m_checkedPixmap.size()); } }else{ if(isEnabled()){ } } }