这就像QTabBar中的可关闭选项卡。
就绪:::::::::::::::::::::
BtnWithClosing::BtnWithClosing(QString txt, QWidget *parent):
QPushButton(txt, parent) {
QHBoxLayout *layout = new QHBoxLayout;
layout->setMargin(4);
layout->setSpacing(0);
layout->setSizeConstraint(QLayout::SetMaximumSize);
setText(text() + " "); // for close button space
QPushButton *btnClose = new QPushButton;
btnClose->setStyleSheet("QPushButton:hover {image:"
"url(:/images/closebtnover.png);}"
"QPushButton {image: url(:/images/closebtn.png); margin-right: -9;"
"margin-left: -6; min-width: 0; background-color: transparent;"
"min-height: 0; border-width: 0px; border-radius: 9px; padding: 0px;}");
layout->addWidget(btnClose, 0, Qt::AlignRight);
setLayout(layout);
}