1. 程式人生 > 其它 >Qt qpushbutton上新增圖片和文字

Qt qpushbutton上新增圖片和文字

技術標籤:qtqt5

在button上新增圖片和文字,通過background-image、border-image、setIcon、pixmap等方式新增圖片,都無法做到圖片在上,文字在下。

步驟一:在pushbutton 直接輸入文字,調整文字位置

步驟二:

QLabel* image_label_3 = new QLabel;
image_label_3->setFixedSize(50,50);
image_label_3->setStyleSheet("QLabel{border-image:url(:/img/config.png)}");
QVBoxLayout *
topLayout_3 = new QVBoxLayout(); topLayout_3->addWidget(image_label_3); topLayout_3->setContentsMargins(40,6,0,20); ui->btn_3->setLayout(topLayout_3);

在這裡插入圖片描述