qgraphicsview

pyqt add rectangle in Qgraphicsscene

本小妞迷上赌 提交于 2019-11-28 05:43:26
问题 I have a scene like this class Scene(QtWidgets.QGraphicsScene): def __init__(self, parent=None): super(Scene, self).__init__(parent) def mousePressEvent(self, event): print('scene pressed') self.wid = MyRect(event.pos(), event.pos()) self.addItem(self.wid) self.wid.show() I would like class MyRect(QtWidgets.QGraphicsRectItem) with painter, mouse event and so on to be a draggable rectangle. all stuff in MyRect So then I could have many Rectangle to the scene and even after draw line between

GIF animation in Qt

依然范特西╮ 提交于 2019-11-28 04:43:44
I have used QGraphicsView , QGraphicsScene classes in order to show a picture in a widget like this: m_Scene->addPixmap(QPixmap(fileName)); m_View->setScene(m_Scene); How I can show .gif animation in the same scene? mosg I don't use GIF animation with QGraphicsView or QGraphicsScene , I use it only in QDialog , but I think it's the same stuff, so here is my code: QMovie *movie = new QMovie(":/images/other/images/16x16/loading.gif"); QLabel *processLabel = new QLabel(this); processLabel->setMovie(movie); movie->start(); My loading.gif I took from this link. PS: also check the examples from Qt

Qt5 C++ QGraphicsView: Images don't fit view frame

点点圈 提交于 2019-11-28 02:40:56
问题 I'm working on program which shows user some picture that is selected by him. But there is a problem because I would like to fit this picture in QGraphicsView's frame and the picture is really smaller than the frame. So here's my code: image = new QImage(data.absoluteFilePath()); // variable data is defined when calling this method scn = new QGraphicsScene(this); // object defined in header ui->graphicsView->setScene(scn); scn->addPixmap(QPixmap::fromImage(*image)); ui->graphicsView-

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

how to pan images in QGraphicsView

不问归期 提交于 2019-11-27 19:47:42
I am currently able to load my image into a grahpics scene, and then again into a QGraphicsViewer. I am able to implement a zoom feature by dtecting a QEvent::Wheel and then calling the graphicsViews's scale() function. However, I can't seem to figure out how to get the pan functionality working. I basically want to detect when a mouse has clicked down on the image, and then move the image left, right, up or down along with the mouse. As of right now, I basically have a MouseFilter class that is detecting events, and doing different things depending on the event type. I attached that listener

Get visible rectangle of QGraphicsView?

元气小坏坏 提交于 2019-11-27 16:11:48
问题 I've been pulling my hair out with this one for hours. There's a thread here about it, but nothing seems to be working. QGraphicsView::rect() will return the width and height, but the left and top values aren't set properly (always 0 -- ignoring the scrolled amount). I want it in scene coordinates, but it should be easy enough to translate from any system. I have no idea what horizontalScrollBar()->value() and vert are returning...seems to be meaningless jibberish. @fabrizioM: // created here

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

Qt GUI Development - Displaying a 2D grid using QGraphicsView

╄→尐↘猪︶ㄣ 提交于 2019-11-27 03:18:55
问题 I'm new to Qt development so I've being trying to research a solution to a user interface I need to design. My project is to simulate players in an online game moving around a global map. To represent the map I need to display a 2D grid, with each space in the grid representing a region of a map. I then need to display the location of each player in the game. The back-end is all fully working, with the map implemented as a 2D array. I'm just stuck on how to display the grid. The research I

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

how to pan images in QGraphicsView

自作多情 提交于 2019-11-26 19:52:02
问题 I am currently able to load my image into a grahpics scene, and then again into a QGraphicsViewer. I am able to implement a zoom feature by dtecting a QEvent::Wheel and then calling the graphicsViews's scale() function. However, I can't seem to figure out how to get the pan functionality working. I basically want to detect when a mouse has clicked down on the image, and then move the image left, right, up or down along with the mouse. As of right now, I basically have a MouseFilter class that