Can you draw on a QPixmap/ QImage?
I tried the following but it doesn't work:
Qt Code:To copy to clipboard, switch view to plain text mode
Can you draw on a QPixmap/ QImage?
I tried the following but it doesn't work:
Qt Code:To copy to clipboard, switch view to plain text mode
i.e.
Qt Code:
... ...To copy to clipboard, switch view to plain text mode
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
Try adding a brush like
Qt Code:
pixPaint.setBrush(brush2); pixPaint.drawLine(1,5);To copy to clipboard, switch view to plain text mode
Hope that helps!
Last edited by qtUser500; 26th February 2009 at 15:50.
I tried the code
Qt Code:
pixPaint.setPen(myPen); pixPaint.drawLine(5,5, 10,10);To copy to clipboard, switch view to plain text mode
This seems to work quite fine for me:
Qt Code:To copy to clipboard, switch view to plain text mode
I am not able to compile, get an error C2512: 'QLabel' : no appropriate default constructor available. Tried using
Qt Code:
To copy to clipboard, switch view to plain text mode
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.
Last edited by gren15; 27th February 2009 at 17:57.
Did you compile the code wysota gave ?? if changed, what did you write ?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.1. Does a pixmap always need a QLabel to be set to?
Can we see what you tried ?2. I tried on a canvas, where I can get to see the pixmap, but not the line drawn over the pixmap.
gren15 (3rd March 2009)
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:
Qt 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();To copy to clipboard, switch view to plain text mode
I will be glad for any help on this. Thanks
Opps! Forgot to mention it .. yes it is using Qt3.
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.
Last edited by gren15; 2nd March 2009 at 16:34.
Thanks everyone. I was able to resolve it.
Last edited by gren15; 3rd March 2009 at 19:03.
Bookmarks