qgraphicsview

PyQt4: Graphics View and Pixmap Size

旧城冷巷雨未停 提交于 2019-12-13 05:04:31
问题 I'm developing a GUI using QTDesigner for some image processing tasks. I have two graphic views beneath each other in a grid layout. Both should display an image and later on I will add overlays. I create my Pixmap img_pixmap and add it to my Scene. This scene is then added to my graphics view. Since my image is much larger than my screen size I apply fitInView() . In code: self.img_pixmap_p = self.img_scene.addPixmap(img_pixmap) self.img_view.setScene(self.img_scene) self.img_scene

What is the meaning of “the item's view geometry and scene geometry will be maintained separately”?

好久不见. 提交于 2019-12-13 04:43:02
问题 The documentation for the QGraphicsItem::ItemIgnoresTransformations flag says The item ignores inherited transformations (i.e., its position is still anchored to its parent, but the parent or view rotation, zoom or shear transformations are ignored). This flag is useful for keeping text label items horizontal and unscaled, so they will still be readable if the view is transformed. When set, the item's view geometry and scene geometry will be maintained separately . You must call

PyQt/PySide QSpinBox flickering issue

蹲街弑〆低调 提交于 2019-12-13 01:26:02
问题 I have added a QSpinBox to a QGraphicsScene using a QGraphicsProxyWidget. Each time I hover over the QSpinBox, it flickers with a black band overlaid on the spinbox controls. I have attached a screenshot and the code below. Am I doing something wrong? Is there a way to avoid this? Pyside 1.1.2, Python 2.7, Windows7. class testWidget(QGraphicsView): def __init__(self): QGraphicsView.__init__(self) floorSpinBox = QSpinBox() floorSpinBox.setGeometry(0,0,50,25) proxyWidget = QGraphicsProxyWidget(

QGraphicsView / QGraphicsScene size matching

被刻印的时光 ゝ 提交于 2019-12-12 13:31:44
问题 How do you make a QGraphicsScene with a specified size and a QGraphicsView to monitor that scene with the same size? This sounds like a stupid question but consider the following test code [1] import sys from PyQt4 import QtGui, QtCore class MainWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.scene = QtGui.QGraphicsScene(0, 0, 200, 200, self) self.view = QtGui.QGraphicsView(self.scene, self) #self.view.setMaximumSize(200, 200) self.setCentralWidget(self

Getting started with a Tile-based game in Qt using QGraphicsScene and QGraphicsView

拜拜、爱过 提交于 2019-12-12 07:57:10
问题 I'm going to start programming a 2D tile-based game in Qt and read about the QGraphicsScene and QGraphicsView classes which are intended for displaying and handling lots of 2D objects. My question is that will it be feasible to create a world with lots of tiles using QGraphicsScene? Can I add the whole world at once tile-by-tile or should I try to implement something to restrict the area a bit? I've read that QGraphicsScene can handle "thousands of items" but a 2D tile map can easily get

setpixel of QGraphicsScene in Qt

南楼画角 提交于 2019-12-12 03:19:41
问题 It's simple to draw line or ellipse just by using scene.addellipse(), etc. QGraphicsScene scene(0,0,800,600); QGraphicsView view(&scene); scene.addText("Hello, world!"); QPen pen(Qt::green); scene.addLine(0,0,200,200,pen); scene.addEllipse(400,300,100,100,pen); view.show(); now what should i do to set some pixel color? may i use a widget like qimage? by the way performance is an issue for me.thanks 回答1: I think that performing pixel manipulation on a QImage would slow down your application

Qimage: out of memory, returning null image

随声附和 提交于 2019-12-12 02:06:54
问题 I am writing a code to show a video in a graphicsView QObject. It goes like this: void MainWindow::UpdateVideo() { cap >> frame; cvtColor(frame, frame,CV_BGR2RGB); QImage Qframe = QImage((uchar*) frame.data, frame.cols, frame.rows, frame.step, QImage::Format_RGB888); QPointer<QGraphicsScene> VideoScene = new QGraphicsScene; VideoScene->addPixmap(QPixmap::fromImage(Qframe)); ui->VideoView->setScene(VideoScene); ui->VideoView->show(); } void MainWindow::on_pushButton_2_clicked() { cap.open(

Rotate - TransformOriginPoint - PyQt4

元气小坏坏 提交于 2019-12-11 13:55:00
问题 I was trying to build a small UI using PyQt . It has a window , a button(Rotate) , and a polygon(rectangle) in a QGraphicsView. One aim of the app is to allow the user to rotate the polygon. That is after the button is clicked and the user clicks at a point , the nearest vertex automatically shifts or tilts towards the user click. Ive also set the polygon to be movable before the click and not movable after the click. The problem is if the user moves the polygon and then clicks , the polygon

Why do my my line widths looks different in a QGraphicsScene with the same QPen width?

 ̄綄美尐妖づ 提交于 2019-12-11 13:12:29
问题 I use a QPainter to draw my widget with this code: QPen pen(Qt::black, 0.6, Qt::SolidLine); QPainter painter(this); painter.setPen(pen); // vertical painter.drawLine(startX,0,startX,50); painter.drawLine((startX += grid),0,startX,50); painter.drawLine((startX += grid),0,startX,50); painter.drawLine((startX += grid),0,startX,50); painter.drawLine((startX += grid),0,startX,50); painter.drawLine((startX += grid),0,startX,50); // horizontal pen.setWidth(0.7); painter.setPen(pen); painter.drawLine

Qt can't connect a subclass of QGraphicsView signal (not inherited) to SLOT

旧街凉风 提交于 2019-12-11 10:42:44
问题 I defined class MyGraphicsView, a subclass of QGraphicsView. Than, I add a signal test() in MyGraphicsView. In my MainWindow class, I have MyGraphicsView* myView and I connect like: connect(myView, SIGNAL( test() ) , this, SLOT( zoom() )) ; But I got: QObject::connect: No such signal QGraphicsView::test() in ..\Proto_version_2\mainwindow.cpp:73 回答1: In order to use slots and signals in a class, it must be derived from either QObject or a QObject derived class and your class must include the Q