//构建最小化、最大化、关闭按钮
minButton = new QToolButton(this);
closeButton= new QToolButton(this);
maxButton= new QToolButton(this);
//获取最小化、关闭按钮图标
QPixmap minPix = style()->standardPixmap(QStyle::SP_TitleBarMinButton);
QPixmap closePix = style()->standardPixmap(QStyle::SP_TitleBarCloseButton);
maxPix = style()->standardPixmap(QStyle::SP_TitleBarMaxButton);//最大化需要在事件中进行判断更换图标所以设置成数据成员
//设置最小化、关闭按钮图标
minButton->setIcon(minPix);
closeButton->setIcon(closePix);
maxButton->setIcon(maxPix);
//设置最小化、关闭按钮在界面的位置
int wide = width();//获取界面的宽度
minButton->setGeometry(wide-65,5,20,20);
closeButton->setGeometry(wide-25,5,20,20);
maxButton->setGeometry(wide-45,5,20,20);
//设置鼠标移至按钮上的提示信息
minButton->setToolTip(tr("最小化"));
closeButton->setToolTip(tr("关闭"));
maxButton->setToolTip(tr("最大化"));
//设置最小化、关闭按钮的样式
minButton->setStyleSheet("background-color:transparent;");
closeButton->setStyleSheet("background-color:transparent;");