Pixmap do not getting set in label
Hi
Might be this question i should not ask but i am not understanding what is wrong with this. I am trying to set a pixmap to a label (here label is my custom label class in which i inherit paintEvent() and mousePressEvent()) , but it is not getting display. I checked whether image is loaded or not , i found that image is loaded correctly.
My code for setting pixmap is
QPixmap image1(":/buttonn.png");
this.setPixmap(QPixmap::fromImage(image1));
if(image1.isNull()){
label->setText("null pic");
}
Thanks.
Re: Pixmap do not getting set in label
Quote:
Originally Posted by
Niamita
QPixmap image1(":/buttonn.png");
this.setPixmap(QPixmap::fromImage(image1));
? image1 is already a pixmap. So simple use
Code:
this.setPixmap(image1);
Re: Pixmap do not getting set in label
thank you Lykurg for immediate response, but i am still not successful in setting pixmap to label.
Re: Pixmap do not getting set in label
Then please post a little bit more code or even better, make a compilable example reproducing your problem. Because the error seems not to be in your posted code.
Re: Pixmap do not getting set in label
Ok
i have a class in which i make instance of my custom label class.
In my custom label claas i am trying to set pixmap in my class constructor with above posted code. i override paintEvent() and mousePressEvent() method only in that class excepting setting pixmap.
I am not getting what i am doing wrong.
Re: Pixmap do not getting set in label
how does the paintEvent() looks like? Maybe you simply do not draw the pixmap? This works normaly fine:
Code:
{
Q_OBJECT
MyLabel(...)
{
setPixmap("...")
}
};
Re: Pixmap do not getting set in label
i solved the problem by setting a label as its child.
well thanks Lykurg for responsing.
Thank you.