Skip to content

Help Required#1

Open
Ishani1125 wants to merge 1 commit intofadyosman:masterfrom
Ishani1125:patch-1
Open

Help Required#1
Ishani1125 wants to merge 1 commit intofadyosman:masterfrom
Ishani1125:patch-1

Conversation

@Ishani1125
Copy link

Hi Fadyosam I was going through your code I want to draw all the graphics item in your example by dragging mouse.
So it will be helpful if you modify your code and upload.

Hi Fadyosam I was going through your code I want to draw all the graphics item in your example by dragging mouse.
So it will  be helpful if you modify your code and upload.
@fadyosman
Copy link
Owner

fadyosman commented Apr 1, 2017

Hi there, Sorry but I really don't have the time to modify the code however it's pretty easy you need to add the lines from the constructor of MainWindow that are responsible for creating items into the drop event of the QGraphicsScene for example (pixmap):
BasicShapesItem *item = new BasicShapesItem(12,12,200,200,BasicShapesItem::ITEM_PIXMAP,scene);
item->setPos(0,100);
item->setPixmap("://Resources/character_design.jpg");

Since the custom items inherits QGraphicsItem you can borrow the code for dragging and dropping available in one of the examples provided by Qt.

@bonnylu
Copy link

bonnylu commented Mar 13, 2019

hi, fadyosman, thanks for sharing.
I was trying to implement 2 BasicShapesItems in different scenes, but it seems the scene()->update(); will have some problem. do you have some suggestions?

sample code:
rect1 = new BasicShapesItem(24,24,185,350,BasicShapesItem::ITEM_RECTANGLE,scene1);
rect2 = new BasicShapesItem(24,24,185,350,BasicShapesItem::ITEM_RECTANGLE,scene2);

if both rect1 and rect2 are selected, the ui can not move.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants