qgraphicsview

Issue with fitInView of QGraphicsView when ItemIgnoresTransformations is on

浪子不回头ぞ 提交于 2019-12-20 03:50:48
问题 While trying to implement a scene where item sizes do not change but distances between items get magnified I encountered this problem with the following code which draws a rectangle and the text "A". Now if I set the flag ItemIgnoresTransformations on the rectangle item, zooming in causes the rectangle to vanish (click and drag mouse button around the rectangle). But that does not happen in case of the text. Also, the new viewport area set by fitInView is very different for I asked for:

QGraphicsItem doesn't receive mouse hover events

百般思念 提交于 2019-12-19 12:24:35
问题 I have a class derived from QGraphicsView , which contains QGraphicsItem -derived elements. I want these elements to change color whenever the mouse cursor hovers over them, so I implemented hoverEnterEvent (and hoverLeaveEvent ): void MyGraphicsItem::hoverEnterEvent(QGraphicsSceneHoverEvent* event) { update (boundingRect()); } However, this event handler code is never executed. I've explicitly enabled mouse tracking: MyGraphicsView::MyGraphicsView(MainView *parent) : QGraphicsView(parent) {

Removing dotted rectangle on selected item

安稳与你 提交于 2019-12-19 11:27:46
问题 I have been trying to learn a bit more about the QGraphicsView widget by taking a look at this example here: Toggle QPen for selected items after QGraphicsScene selection change I found this fairly helpful, however i noticed that upon selection there is marquee thing that pops up when an item is selected. I was looking at ways to get rid of this, and it seems like there is a consistent answer to this in C++ which I see as an example here: https://www.qtcentre.org/threads/39659-About

Drawing widgets (such as buttons) over QGraphicsView

∥☆過路亽.° 提交于 2019-12-19 04:49:21
问题 How do I draw interactive widgets such as QButtons and Line Edits over a QGraphicsView? For ex, I have selected a region over an image in an image editing app which displays an image with QGraphicsView, and I want to annotate this region with a name. So I want to have a Line edit and two buttons (Cross and Tick) below this rectangular selection. How do I draw these? Sample code would be cool! 回答1: QGraphicsScene has a function addWidget() where you can add a widget to a scene. If you don't

How can I draw inside existing QGraphicsVIew?

孤者浪人 提交于 2019-12-18 17:32:11
问题 just like the title says i'm trying to draw inside an existing QGraphicsView. The window I generated using QT Designer, and I would like to draw a matrix of 16x16 squares inside the QGraphicsView . This is the code I have as of right now: Window: # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'untitled.ui' # # Created by: PyQt5 UI code generator 5.8.2 # # WARNING! All changes made in this file will be lost! from PyQt5 import QtCore, QtGui, QtWidgets class Ui

Qt Widgets and derived classes

我怕爱的太早我们不能终老 提交于 2019-12-18 09:44:07
问题 I am wondering if there is a way to do this. I create a Qt Application (using Creator 3.6.1, Qt 5.6.0). I add a widget to the main window. For example a QGraphicsView called myView. I create a C++ class derived from QGraphicsView (called DerivedView) code of DerivedView class: class DerivedView : public QGraphicsView { ... I would like my new DerivedView class to control this widget. I can access a pointer to the object through ui->myView. Is there any way to do get my derived class to work

GIF animation in Qt

拈花ヽ惹草 提交于 2019-12-17 17:40:30
问题 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? 回答1: 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-

How to put an image in QGraphicsView's scrollbar area?

别来无恙 提交于 2019-12-14 03:59:23
问题 Due to some restrictions image has to be in the class QMainWindow and scrollbars have to be the QGraphicsView class. This means that I have to add image in QGraphicsView class through QMainWindow class. "exit.png" exists in the folder from where I run this code. What is the proper way to add this picture? import sys from PyQt4 import QtGui from PyQt4 import QtCore class Window(QtGui.QGraphicsView): def __init__(self, parent=None): QtGui.QGraphicsView.__init__(self, parent) self.scene = QtGui

How to resize QWidget added in QGraphicScene through QGraphicsProxy?

非 Y 不嫁゛ 提交于 2019-12-14 03:57:24
问题 I have added a widget to a graphic scene (QGraphicScene) through a QGraphicsProxyWidget. To move and select the widget added QGraphicsRectItem handle. To resize widget added QSizegrip to widget. But when i resize widget more than the QGraphicsRect item rect right and bottom edges goes behind .How to overcome this problem? When i resize widget graphics rect item should resize or vice-versa should happen. how to do this? Any other ideas are welcome. Here is the code auto *dial= new QDial(); //

QGraphicsSceneMouseEvent get position will not work [duplicate]

大憨熊 提交于 2019-12-13 20:22:23
问题 This question already has an answer here : Qt Widgets and derived classes (1 answer) Closed 2 months ago . I am trying to make an application with a QGraphicsView in it. I tried to get the position of a mouse when the mouse was pressed with QGraphicsSceneMouseEvent, but it doesn't seem to work. The entire function is never called when I press the mouse. I would like to make an application that can load an image into the QGraphicsView and then when you press the mouse button, it should add a