Question

I'm writing a gui application and I must display an image on a label that has been promoted into a class(my_qlabel). I upload the image using a dialog in the other class, and call a function in "my_qlabel" to display it.

void my_qlabel::displayImage(QString filename){
     QPixmap pic (filename);
     //..i dont know the relevant lines i should include here to display....
}
Was it helpful?

Solution

QLabel class has a setPixmap(const QPixmap &) function. Since you are subclassing QLabel class, you can use the same function in your class.

void my_qlabel::displayImage(QString filename){
    QPixmap pic (filename);
    setPixmap(pic);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top