... ui->setupUi(this); scene = new QGraphicsScene(this); ui->graphicsView->setScene(scene); ...
scene->setSceneRect(0, 0, Size + 50, razmer_sceni_po_y - 30);
QGraphicsItem *item = new Grafik(...);
C++ (Qt)ui->graphicsView->mapToScene( QRect( 0, 0, ui->graphicsView->viewport()->width(), ui->graphicsView->viewport()->height() ) )
QGraphicsItem *item = new Grafik(model, Qt::red, 3, min, max);item->setPos(QPointF(0, 200));
Grafik::Grafik(QStandardItemModel *model, const QColor &color, int stolbec, int min, int max)
QRectF Grafik::boundingRect() const{ return QRectF(0, 0, size_x + 5, size_y);}
QPainterPath Grafik::shape() const{ QPainterPath pathik; pathik.addPath(path); return pathik;}
void Grafik::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){ Q_UNUSED(widget); painter->setPen(QPen(color)); painter->drawPath(path);}
This member is only initialized for items that have the QGraphicsItem::ItemUsesExtendedStyleOption flag set.
graphicsView->mapToScene( QRect( 0, 0, ui->graphicsView->viewport()->width(), ui->graphicsView->viewport()->height() ) )
item->setCacheMode(QGraphicsItem::ItemCoordinateCache); и item->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
ui->graphicsView->setOptimizationFlags(QGraphicsView::DontSavePainterState);ui->graphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);ui->graphicsView->setCacheMode(QGraphicsView::CacheBackground);
QGraphicsItem *itema = new Grafik(model, Qt::green, 4, min, max);