Can you draw on a QPixmap/ QImage?
I tried the following but it doesn't work:
Printable View
Can you draw on a QPixmap/ QImage?
I tried the following but it doesn't work:
Pass a pointer to the pixmap.
i.e.
;)
What is the current code?
This seems to work quite fine for me:
Code:
I am not able to compile, get an error C2512: 'QLabel' : no appropriate default constructor available. Tried using
1. Does a pixmap always need a QLabel, for it to be set to?
2. I tried on a different widget like canvas and listbox, here I see the pixmap, but not the line drawn over the pixmap.:confused:
Did you compile the code wysota gave ?? if changed, what did you write ?Quote:
I am not able to compile, get an error C2512: 'QLabel' : no appropriate default constructor available.
Nope, pixmap is a paintdevice, and can be rendered onto any widget. using QLabel for showing pixmap is the simplest way since you dont need to DRAW the pixmap onto the painter, but simply set a pixmap for the label.Quote:
1. Does a pixmap always need a QLabel to be set to?
Can we see what you tried ?Quote:
2. I tried on a canvas, where I can get to see the pixmap, but not the line drawn over the pixmap.
The eventual direction I want to take is to create a listbox with pictures of animals. I want to select a few pictures (Eg grassland animals) and surround them with a green rectangle.
This is what I tried:
Code:
QListBoxPixmap *animalItem = new QListBoxPixmap(animalListBox, pxWolf, "wolf"); // displays fine, I see the pixmap and the text // I want to border this animal with a green line borderPainter->setPen(Qt::green); borderPainter->begin(&pxWolf); borderPainter->end();
I will be glad for any help on this. Thanks
Is the question related to Qt3?
Opps! Forgot to mention it .. yes it is using Qt3.
Can you prepare a minimal compilable example reproducing the problem?
Tweaking the QT listbox example, I have enclosed an executable version of what I want to do.
Quick question: To resize the pixmap to a different size from the default size, I tried the resize function but it cuts the image, not resize it. I have also added this in the enclosed file.
Code:
pixmap.resize(50,80);
Thanks everyone. I was able to resolve it.:D