QPushButton *ab1;
ab1 = new QPushButton(tr("TestButton"), this);
ab1->setStyleSheet("background-color: rgb(224, 0, 0); border-style: inset;");
ab1->blink(green);
ab1->stopblink();
C++ (Qt)TestDialog::TestDialog(){ QPushButton *btn1_1 = new QPushButton( this ); btn1_1->setObjectName( "Type 1" ); QPushButton *btn1_2 = new QPushButton( this ); btn1_2->setObjectName( "Type 1" ); QPushButton *btn1_3 = new QPushButton( this ); btn1_3->setObjectName( "Type 1" ); QPushButton *btn2_1 = new QPushButton( this ); btn2_1->setObjectName( "Type 2" ); QPushButton *btn2_2 = new QPushButton( this ); btn2_2->setObjectName( "Type 2" ); QPushButton *btn2_3 = new QPushButton( this ); btn2_3->setObjectName( "Type 2" );}
QPushButton#Type1 { background-color: red; border-style: outset; border-width: 2px; border-radius: 10px; border-color: beige; font: bold 14px; min-width: 10em; padding: 6px; } QPushButton#Type1:pressed { background-color: rgb(224, 0, 0); border-style: inset; }QPushButton#Type2 { background-color: green; border-style: outset; border-width: 2px; border-radius: 10px; border-color: beige; font: bold 14px; min-width: 10em; padding: 6px; } QPushButton#Type2:pressed { background-color: rgb(224, 0, 0); border-style: inset; }
C++ (Qt)class MyButton : public QPushButton{ Q_OBJECTpublic: MyButton( QWidget *parent = 0 ); private: QTimer *m_timer;}; MyButton::MyButton( QWidget *parent = 0 ) : QPushButton( parent ){ m_timer = new QTimer( this );}