qt 之 QPushbutton

2019-04-15 13:41发布

1)设置图片的三态
ui.colorButton->setStyleSheet("QPushButton {border-image:url(pic/border-image.jpg); font-size:24px;}
  QPushButton:hover:pressed {border-image:url(pic/pressed.jpg);font-size:24px;}
  QPushButton:hover:!pressed {border-image:url(pic/hover.jpg);font-size:24px;} ");
2)去掉图片边缘透明 {MOD}     ui->btnOrderLater->setFlat(true);
    ui->btnOrderLater->setStyleSheet("background-image:url(:/image.png);");

3)文字居右 setStyleSheet ("text-align: right");