我正在用QPainterPath在画图场景上画一个多边形。但是,当我想要删除路径时,我无法删除它。有人能告诉我如何删除/删除绘制的路径吗?我正在尝试下面的代码。
In header File:
QGraphicsScene *scene;
QGraphicsPixmapItem *m_pixItem;
QPainterPath m_pathTrack;
QPolygon m_qpolygon;
In cpp file
void MyClass::AddPath()
{
//Slot to add path to the scene
QImage l_img("
我正在PyQt中开发一个程序,并创建一个小部件,在该网格上显示一个网格和一组多边形,您可以在这个网格上移动并单击。当我尝试实现对多边形的点击时,它似乎不起作用。以下是不起作用的函数:
def mouseMoveCustom(self, e):
for poly in reversed(self.polys):
if poly.contains(e.pos()):
self.cur_poly = poly
self.setCursor(Qt.PointingHandCursor)
print('
我试图对一个QPolygon进行筛选,然后加载它,但是我得到了一个错误。我已经在Python2和PyQt4上完成了这项工作,但现在我想在Python3和PyQt5上使用它。
我不想读取/加载使用Python2生成的数据!pickle文件只是用来将Qt元素从Python3临时存储到Python3中,比如QPolygons。
我已经为pickle.dump()测试了从1到4的不同协议选项,并尝试使用"fix_imports=True“选项,这在Python3中应该不会有什么不同。
以下是我的简化代码
from PyQt5.QtGui import QPolygon
from PyQt5.Q
我正在尝试获取蓝色和绿色QPolygons的交叉点,以及它构成蓝色QPolygon的百分比(见下图)。
我按如下方式创建了多边形:
import PyQt5
from PyQt5 import QtWidgets,QtGui,QtCore
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys, math
class MyWidget(QtWidgets.QWidget):
def __init__(self, parent=None):
我正在寻找一种方法来找到一组完全包含在QPolygon中的正方形,它不一定是凸的。
QRectF boundingRect(mShape->boundingRect());
for (int x = boundingRect.x() - 1; x < boundingRect.width(); x++)
{
for (int y = boundingRect.y() - 1; y < boundingRect.height(); y++)
{
QRectF rect(x, y, 1, 1);
QPolygonF cell(rec
我对Qt非常陌生,我遇到了一个我找不到解决办法的问题。
因此,我的问题如下:
我试图在类中生成一个QtLabel,并在mainWindow中显示它。
class Hexagon
{
public:
QPolygon polygon;
QLabel *cellText = new QLabel(this);
Hexagon(int startX, int startY, int length, int row, int cell, char letters[26])
{
polygon <&l
我正在使用PyQt5。我正在编写一个机器人在迷宫中移动的程序。为此,我使用QGraphicsScene。我添加了像QRect这样的对象来表示机器人。背景是通过SetBackgroundBrush设置的,并从png图像加载(黑色表示无法通过的地形):
def update_background(self):
qim = QImage(self.model.map.shape[1],self.model.map.shape[0], QImage.Format_RGB32)
for x in range(0, self.model.map.shape[1]):