Try using QGraphicsPixmapItems instead of trying to paint images by hand.
Try using QGraphicsPixmapItems instead of trying to paint images by hand.
J-P Nurmi
QGraphicsPixmap items? I tried, picture is shown, but I cannot move it to arbitrary coordinate.
Qt 5.3 Opensource & Creator 3.1.2
You can move them like any other items; QGraphicsItem::setPos().
J-P Nurmi
But what is the difference between my current approach and qpixmapitem approach?
Qt 5.3 Opensource & Creator 3.1.2
What's the point using a QGraphicsScene/QGraphicsView without items? QGraphicsView has a sophisticated paintEvent() will its caching facilities and such. There are specialized QGraphicsView::draw*() and QGraphicsItem::paint() methods in case you want to draw anything by hand. I wouldn't suggest reimplementing QGraphicsView::paintEvent(), it will just destroy the fine framework.
J-P Nurmi
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
Bookmarks