qgraphicsscene

Getting NetworkX edge 'weight' to show in QGraphicsScene

淺唱寂寞╮ 提交于 2019-12-23 02:54:10
问题 I've been trying to figure out how to get NetworkX to present very nicely into a QGraphicsScene . I need it to be able to show the 'weight' of each edge, which is the amount of times Company1 was in contact with Company2 . The scripts that I have below is a working demo of getting the Nodes and Edges presented into the GUI..but because I'm assigning only the Nodes and Edges, I cannot get the 'weight' or colors at that...but I think I have a way of assigning colors after the fact of placing

how to create a pie chart with pyqt in python

泄露秘密 提交于 2019-12-22 14:14:46
问题 Trying to create a pie chart shape but for some reason I can't get it to join together correctly. When I run my code It creates a lot of segments on top of each other. Here is my code: from PyQt4.QtCore import * from PyQt4.QtGui import * import sys, random app = QApplication(sys.argv) scene = QGraphicsScene() families = [1,2,3,4,5,6,7] total = 0 colours = [] set_angle = 0 count1 = 0 total = sum(families) for count in range(len(families)): number = [] for count in range(3): number.append

Iterator for elements in QGraphicsScene

不羁的心 提交于 2019-12-22 10:55:05
问题 I have a QGraphicsScene which contains custom objects (with QGraphicsItem as base class). I can retrieve these objects with: foreach (QGraphicsItem* item, items()) { if (item->type() == CustomItem::Type) qgraphicsitem_cast<CustomItem*>(item).doStuff(...); } Is it possible to write a custom iterator for just this type of objects? I want to be able to use range-based for-loops and algorithms from the STL. for(CustomItem& a : custom_items()) a.doStuff(...); I want to avoid storing pointers to

QGraphicsScene::~QGraphicsScene() segmentation fault

倖福魔咒の 提交于 2019-12-22 09:39:34
问题 Good day! With Qt 4.7.3 an example below crashes at QGraphicsScene::~QGraphicsScene() call: #include <QCoreApplication> #include <QGraphicsScene> int main( int argc, char* argv[] ) { // replace this with QObject app; and no problems QCoreApplication app( argc, argv ); new QGraphicsScene( &app ); return 0; } Any ideas? UPDATE: Bug report created. 回答1: When a QGraphicsScene instance is constructed it appends itself in a list stored in a private member of the single QApplication instance, and

QImage in a QGraphics scene

柔情痞子 提交于 2019-12-20 10:35:19
问题 I am quite new to Qt. I am having troubles in inserting a QImage to a scene. Could somebody please tell me how to add a QImage to a QGraphicsScene ? 回答1: For this you would use a QGraphicsPixmapItem that you add to the scene like any other QGraphicsItem . The QGraphicsPixmapItem can be initialized with a QPixmap which is a device-dependent representation of a bitmap and you can get it from a QImage for example with the static function QPixmap::fromImage(). Update (example code) #include

How can i make 2-layers in QGraphicsView?

不想你离开。 提交于 2019-12-20 05:28:05
问题 In the program below, load the background image and paint it on it. But, I got a problem. In this program, when i use 'eraser' tool, the background image is erased too! Actually, I just want to erase what i painted, except background image. And then, I'd like to save only the painted ones(layer) as an image. In this case, What should i do? import sys from PyQt5.QtCore import * from PyQt5.QtCore import Qt from PyQt5.QtGui import * from PyQt5.QtWidgets import * from PyQt5.QtWidgets import

itemAt not returning custom qGraphicsItem

一世执手 提交于 2019-12-20 02:34:16
问题 I have a custom implementation of qGraphicsScene and a custom qGraphicsItem that I click on, but the itemAt function never returns a value, even though I am fairly certain that I'm clicking on the item. void VScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if ((vMouseClick) && (event->pos() == vLastPoint)) { QGraphicsItem *mod = itemAt(event->pos(), QTransform()); if (mod) { // Never returns true // ... } } } For clarity, the module is added in the following code: void VScene:

How to move around 1000 items in a QGraphicsScene without blocking the UI

流过昼夜 提交于 2019-12-19 09:37:36
问题 I have around 1000 graphics item in my QGraphicsScene . I want to move all of these 1000 items to new position. New positions don't relate to each other and all of them should be done at the same time. One way is to iterate through these 1000 items and call setPos for each one ! I think this will block user interface. Another way is to draw an image in another thread and to set this image as a result in QGraphicsScene! May you have another idea.I'm looking forward to hearing that ! 回答1: Qt

How to move around 1000 items in a QGraphicsScene without blocking the UI

送分小仙女□ 提交于 2019-12-19 09:35:52
问题 I have around 1000 graphics item in my QGraphicsScene . I want to move all of these 1000 items to new position. New positions don't relate to each other and all of them should be done at the same time. One way is to iterate through these 1000 items and call setPos for each one ! I think this will block user interface. Another way is to draw an image in another thread and to set this image as a result in QGraphicsScene! May you have another idea.I'm looking forward to hearing that ! 回答1: Qt

How to use QPainter on QPixmap

寵の児 提交于 2019-12-18 14:52:18
问题 I'm a newbie to Qt/Embedded. I want to use QPainter to draw stuff on a QPixmap , which will be added to QGraphicsScene . Here is my code. But it does not show the drawings on the pixmap. It shows only the black pixmap. int main(int argc, char **argv) { QApplication a(argc, argv); QMainWindow *win1 = new QMainWindow(); win1->resize(500,500); win1->show(); QGraphicsScene *scene = new QGraphicsScene(win1); QGraphicsView view(scene, win1); view.show(); view.resize(500,500); QPixmap *pix = new