How do I add QImage to QGraphicsScene? I am reading docs and I just do not get it ...![]()
How do I add QImage to QGraphicsScene? I am reading docs and I just do not get it ...![]()
Qt 5.3 Opensource & Creator 3.1.2
Again, use QGraphicsPixmapItems. I thought you said you already got one visible.You may use QPixmap::fromImage() to convert a QImage to QPixmap.
J-P Nurmi
I tried to used it before, something did not work. I gor some errors about QGraphicsPixelItem contructor that is private or sometinhg lke that.
Qt 5.3 Opensource & Creator 3.1.2
The copy constructor of QGraphicsPixmapItem is private which means that you cannot copy QGraphicsPixmapItems.
The easiest way is to use the convenience method of QGraphicsScene:
but you can create QGraphicsPixmapItems yourself as well:Qt Code:
item->setPos(...);To copy to clipboard, switch view to plain text mode
Qt Code:
scene->addItem(item); item->setPos(...);To copy to clipboard, switch view to plain text mode
J-P Nurmi
Qt 5.3 Opensource & Creator 3.1.2
It's a programmatical technique to prevent objects from getting copied. Sometimes it makes no sense to copy an object, like a QObject or a QGraphicsItem. Both QObjects and QGraphicsItems are organized in object trees where each object has an optional parent and children. What should happen when such object is copied? Should children get copied? Should parent get copied as well? Should possible signal-slot connections get copied? What person A would expect to happen would be most likely different than person B would expect. The result would be chaotic no matter how the functionality was implemented. Therefore it's just better to prevent it from happening.
PS. Did you notice that your signature says "kUbutnu"?![]()
J-P Nurmi
Ok, jpn, I again tumbed into wall. Loaded pics are different sizes, how do I limit the size of every loaded pic to, for example, to 100x100 points?
Qt 5.3 Opensource & Creator 3.1.2
Heh, it's been buggering me for a while but I couldn't resist myself anymore..
Well, it depends a bit what you want to achieve. Both QPixmap and graphics items are scalable. See QPixmap::scaled() and QGraphicsItem::scale().
J-P Nurmi
Well, these pictures will be placed on "ghost" circle coordinates. And this is ugly if every pic has different size, so every created pixmap must be scaled to predefined size, let me try.
And, let me correct signature so you will not bothered again.![]()
Qt 5.3 Opensource & Creator 3.1.2
I don't read signatures
About your question: use QPixmap::scaled() or QImage::scaled().
Bookmarks