qgraphicsitem

Weird “incomplete type” error in a QGraphicsItem [duplicate]

折月煮酒 提交于 2019-12-12 22:08:39
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: What leads to incomplete types? (QGraphicsItem: Source or target has incomplete type) I started out with this question: What leads to incomplete types? (QGraphicsItem: Source or target has incomplete type) As mentioned there, I got the following error (partly my own translation): C664: Conversion of parameter 1 from 'Qt::CursorShape' to 'const QCursor &' not possible. Source or target has incomplete type. While

error: C2248: 'QGraphicsItem::QGraphicsItem' : cannot access private member declared in class 'QGraphicsItem'

这一生的挚爱 提交于 2019-12-12 03:54:37
问题 I encountered the error described on the post title in Qt. I have a class call "ball", and it inherits class call "tableItem" which inherits QGraphicsItem. I'm trying to use prototype design pattern, and thus have included a clone method inside the ball class. Here's my code snippet: For ball header and class #ifndef BALL_H #define BALL_H #include <QPainter> #include <QGraphicsItem> #include <QGraphicsScene> #include <QtCore/qmath.h> #include <QDebug> #include "table.h" #include "tableitem.h"

Size QGraphicsItem based on string length

女生的网名这么多〃 提交于 2019-12-12 02:35:13
问题 I'm looking for the most effective way to size a QGraphicsItem based on the length of a given QString , so that the text is always contained within the QGraphicsItem's boundaries. The idea is to keep the QGraphicsItem as small as possible, while still containing the text at a legible size. Wrapping onto multiple lines at a certain width threshold would be ideal as well. For example, TestModule::TestModule(QGraphicsItem *parent, QString name) : QGraphicsPolygonItem(parent) { modName = name; //

Moving a QGraphicsItem around a central point in PyQt4

有些话、适合烂在心里 提交于 2019-12-11 22:24:37
问题 I'm using Python 2.7 and PyQt4. I am trying to have a half-circle object that is a QGraphicsItem. I want to be able to move it using the mouse, by clicking and dragging. I can create the object and move it around with the mouse by setting the flag ItemIsMovable. Now the half-circle moves around freely but I want it to move just around the fixed central point. It is difficult to describe, but it should be something similar to a dial. How can I accomplish this? 回答1: you can use QGraphicsItem:

Animate ellipses along QPainterPath

不羁的心 提交于 2019-12-11 16:59:58
问题 I have a bunch of ellipses that initially are lined on top of a path and should move along the QPainterPath. I have it working for the first ellipse but I can't figure out how to get the correct position for the other ellipses. Is there a way to check if it passed the end of the path and move it back to the beginning? class Animation : public QAbstractAnimation { public: Animation(const QPainterPath& path, QObject *parent = Q_NULLPTR); virtual void updateCurrentTime(int ms) override; virtual

Draggable pixmaps inside a QGraphicsScene of graphic items

陌路散爱 提交于 2019-12-11 16:52:20
问题 I have a scene with a 12*4 grid with blocks of QGraphicsItems ,when i right click on the blocks I have a contexmenu that can add icons inside the blocks my proplem is that I can't fingure out how can I make those icons draggable to the other blocks inside the graphic scene ,I know there is the "Draggable Icons Example" but how can I implement that code to a graphic scene. this is the mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QGraphicsPathItem>

Qgraphicsscene troubles to get scenePos() inside a function

我的梦境 提交于 2019-12-11 08:26:27
问题 I have subclassed a qgraphicsscene and trying to get the mouse coords inside a "normal" function. I only get it working on "mouse involved" function. Sorry I'm amateur programmer. For exmample here scenePos() works: void mousePressEvent(QGraphicsSceneMouseEvent *event) { // qDebug() << "Custom scene clicked."; if(event->modifiers() == Qt::ControlModifier) { if(event->button() == Qt::LeftButton) { QPointF pos = {event->scenePos().x(), 70}; addChordnueve(pos); // crea 1 item at mouse x e y = 70

animate a QGraphicsPixmapItem

醉酒当歌 提交于 2019-12-11 07:49:12
问题 I am trying to animate a QGraphicsPixmapItem in PyQt5. The program as is crashes without any error message, and removing the lines about the variable 'anime' makes the program work normally. here is the QGraphicsPixMapItem: class QStone(QGraphicsPixmapItem,QGraphicsObject): def __init__(self, color, movable): QGraphicsPixmapItem.__init__(self) QGraphicsObject.__init__(self) if movable: self.setFlag(QGraphicsItem.ItemIsMovable) white = QPixmap("ressources/white2.png") black = QPixmap(

QGraphicsItem paint delay

帅比萌擦擦* 提交于 2019-12-11 07:23:07
问题 What could be the possible reason for this? When i zoom in the QGraphicsView and move the QGraphicsItem, I get this weird result. It does update if I zoom or pan the View again or if I focus on other widgets. Im using PySide. And the painter function is this def paint(self, painter, option, widget): if self.isSelected(): brush = self.highlight_brush pen = self.highlight_pen else: brush = self.dormant_brush pen = self.dormant_pen painter.setBrush(brush) painter.setPen(pen) painter.drawRect(0,

Custom QGraphicsItems not compiling and gives “object is private” error

匆匆过客 提交于 2019-12-11 06:33:18
问题 I am trying to create a Custom QGraphicsItem button as shown by Fred here. The code which he posted can be found here. The problem is when I try and compile the code I get the following two errors: /usr/include/qt4/QtGui/qgraphicsitem.h ‘QGraphicsItem::QGraphicsItem(const QGraphicsItem&)’ is private /usr/include/qt4/QtCore/qobject.h ‘QObject::QObject(const QObject&)’ is private Here is the code snippet which essentially is the same as that in the sample above. The error is on the class