ui->label->setStyelSheet("image:url(:/1.png); border-image:url(:/2.png);");
Why can't the image be displayed after run? But the border-image display normal.
It can display normal in Qtcreator. It can display image in compiler even did not run.
ui->label->setStyelSheet("image:url(:/1. png); border-image:url(:/2. png);");
I think the image
property is for subcontrol only (see doc ), while border-image
is valid for labels.
Use
QPixmap::QPixmap ( const QString & fileName, const char * format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor );
QLabel::setPixmap ( const QPixmap & );
Like this:
QPixmap pix(":/1.png");
ui->label->setStyleSheet("border-image:url(:/2.png);");
ui->label->setPixmap(pix);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With