2
我是Qt新手,我有一個帶有背景圖片的標籤。背景圖像顯示正常,但無法在圖像上顯示。怎麼做?引導我。請參考下我的代碼如何實現:如何在Qt中的圖像上顯示文字?
QImage image("sample.bmp");
myLabel->setPixmap(QPixmap::fromImage(image));
myLabel->setGeometry(10,10,78,78);
我試過QPalette
顯示文本,但如果我使用QPalette
只有文字顯示時,圖像不顯示。我試過QPalette
這樣:
QPalette sample_palette;
sample_palette.setColor(QPalette::Window, Qt::white);
sample_palette.setColor(QPalette::WindowText, Qt::blue);
myLabel->setAutoFillBackground(true);
myLabel->setPalette(sample_palette);
myLabel->setText("What ever text");
這兩個代碼都在工作,但嘿呦的建議是如此簡單 – shivcena