功能和pushButton類型,其餘相似,app
只是將mywidget中改爲了ui
#include "mywidget.h" #include <qapplication.h> #include <qtoolbutton.h> #include <qfont.h> MyWidget::MyWidget(QWidget *parent) : QWidget(parent) { setMinimumSize( 200, 120 ); setMaximumSize( 200, 120 ); QToolButton *quit = new QToolButton(this); quit->setText("quit"); quit->setGeometry( 62, 40, 75, 30 ); quit->setFont( QFont( "Times", 18, QFont::Bold ) ); connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) ); } MyWidget::~MyWidget() { }