[Interest] Image on QLabel doesn't show at all
thiago.macieira at intel.com
Sun Dec 9 05:24:55 CET 2018
On Saturday, 8 December 2018 12:23:22 EST Tamás Nagy wrote:
> pixmap = new QPixmap(imageUrl.toString());
This line is already wrong. QPixmap opens files paths, not URLs.
Why did you create QPixmap in the heap if you only used it here?
> ui->imageLabel->setStyleSheet("background-image: url(" +
> imageUrl.toString() + ")");
This is a conflicting instruction with the setPixmap above. One of the two
will not take effect. If the URL is correctly pointing to something that the
stylesheet could show, then QPixmap in the first line can't open it. If the
QUrl contains an invalid URL that happens to be turn to a valid file path that
QPixmap can open if you do url.toString(), then this stylesheet possibly
points to an invalid URL.
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Interest