qgraphicsscene

Draw an item in a static location relative to the QGraphicsView

我是研究僧i 提交于 2019-11-27 21:36:33
I would like to draw a notification that always appears in the upper right corner of my QGraphicsView . However, QGraphicsItems positions are specified in scene coordinates, so if the user panned/zoomed to view a different part of the scene, this notification would move off screen. I have figured out that I could simulate this behavior by moving and scaling the notification any time the current view changes. But this seems terribly ineffective and not at all elegant. It seems that QGraphicsView should support this kind of behavior. The docs mention a flag ItemIsPanel that sounds hopeful, but

Arc in QGraphicsScene

心已入冬 提交于 2019-11-27 15:53:09
I want to implement arc in QGraphicsScene. I want that on clicking of three points my arc should be drawn such that on clicking of three points arc is drawn where first point will be starting of arc, second will be any point on arc and third will be end point of arc. I have tried studing drawArc function but got confused with startangle and spanangle. I was unable to set them dynamically. Please suggest me some way to proceed. I tried the solution to embend it in my project but got the following error: error: cannot allocate an object of abstract type 'arc' arcItem = new arc(++id, startP, midP

How to draw a point (on mouseclick) on a QGraphicsScene?

。_饼干妹妹 提交于 2019-11-27 08:54:09
I have the following code to set up a QGraphicsScene . I wish to click on the scene and draw a point at the location I've clicked. How could I do this? This is my current code: MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QGraphicsScene *scene; QGraphicsView *view = new QGraphicsView(this); view->setGeometry(QRect(20, 50, 400, 400)); scene = new QGraphicsScene(50, 50, 350, 350); view->setScene(scene); } phyatt UPDATE: There is a new class called QGraphicsSceneMouseEvent that makes this a little easier. I just finished an example

Need QGraphicsScene signal or event for _after_ change

时光怂恿深爱的人放手 提交于 2019-11-26 21:56:33
问题 I use QGraphicsScene of the Qt framework. Inside the scene I have some QGraphicsItem s which the user can select and move. I would like to have an info label where the current x and y coordinate of the currently moved selection (can consist of many items) is displayed. I have tried with the signal changed of QGraphicsScene . But it is fired before the x() and y() property of the items is set to the new values. So the labels always show the second-to-last coordinates. If one moves the mouse

Draw an item in a static location relative to the QGraphicsView

自古美人都是妖i 提交于 2019-11-26 20:28:59
问题 I would like to draw a notification that always appears in the upper right corner of my QGraphicsView . However, QGraphicsItems positions are specified in scene coordinates, so if the user panned/zoomed to view a different part of the scene, this notification would move off screen. I have figured out that I could simulate this behavior by moving and scaling the notification any time the current view changes. But this seems terribly ineffective and not at all elegant. It seems that

Arc in QGraphicsScene

纵然是瞬间 提交于 2019-11-26 17:19:51
问题 I want to implement arc in QGraphicsScene. I want that on clicking of three points my arc should be drawn such that on clicking of three points arc is drawn where first point will be starting of arc, second will be any point on arc and third will be end point of arc. I have tried studing drawArc function but got confused with startangle and spanangle. I was unable to set them dynamically. Please suggest me some way to proceed. I tried the solution to embend it in my project but got the

How to draw a point (on mouseclick) on a QGraphicsScene?

亡梦爱人 提交于 2019-11-26 14:24:15
问题 I have the following code to set up a QGraphicsScene . I wish to click on the scene and draw a point at the location I've clicked. How could I do this? This is my current code: MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QGraphicsScene *scene; QGraphicsView *view = new QGraphicsView(this); view->setGeometry(QRect(20, 50, 400, 400)); scene = new QGraphicsScene(50, 50, 350, 350); view->setScene(scene); } 回答1: UPDATE: There is a new