Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Resoved]How de copy and paste drawn objets



  • I want to copy and past, cut and past objet which i drawn. These object are circle, square, line, image...

    How can i do this with the QClipboard classe?

    Help please



  • Are you using graphicsview, painter ....

    Can you give us more detail please?



  • I'm using QGraphicsScene in which there are a graphicsview, my items are of type QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsItemGroup, QGraphicsLineItem, QGraphicsProxyWidget, QGraphicsPolygonItem, QGraphicsRectItem, QGraphicsSimpleTextItem.

    And I use the addItem() methode of the QGraphicsScene.



  • Anyone can help me



  • In the "GraphicsView docs":http://doc.qt.nokia.com/4.7/graphicsview.html#drag-and-drop you can find some information about drag and drop.

    Have you looked in the examples?



  • I don't want to do a drag and drop. I want to duplicate the drawn objects which are selected in the GraphicsScene by using the QClipboard classe



  • I serialize my objects using QDomDocument what I want now is how to pass this type to QClipboard ??



  • I've resoved my problem. What I do is: when items are selected I serialize them and create a xml text. And I covert the QDomDecoment whitch contain the xml text to string and put the string in the clipboard.

    In the method whitch process the paste I get the text in the clipboar and deserialize it.



  • Well done! Thanks for sharing your solution ;)

    could you change the title to [Solved]?

    [Resoved] will not be recognized when topics will get more functionality to show solved topics in the future. Thanks.



  • hi i am a new to Qt, i couldn't find how u will serialize selected items, if you copy an selected item like which i done below i just get a shallow copy of an item, how do we actually get this selected item and serialize it. plz show it with a small example

    QList<QGraphicsItem *> copiedItem = this->selectedItems();

    All i want to finally do is, i wanted to copy and paste QGraphicItem on my QGraphicScene .

    thanks in advance


Log in to reply