Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. qgraphicsscene
    Log in to post

    • UNSOLVED Render just a specific area of a QGraphicsScene
      General and Desktop • qgraphicsview qgraphicsscene widgets rubber band render to image • • nitro0  

      5
      0
      Votes
      5
      Posts
      70
      Views

      @wrosecrans I know that I need them. But don‘t know how to apply them on the scene and keep everything thats on that. I thought that the rect itself has the points in it using the render function of the QGraphicsScene is enough. What I do: I set the DragMode of the QGraphicsView to rubberband so the user can select some part pf the scene by simply dragging. The returned rect is now sent to the view to get the underlying image of the scene.
    • UNSOLVED QGraphicsView resize issue
      General and Desktop • qgraphicsview qgraphicsscene qpixmap • • Josef Lintz  

      7
      0
      Votes
      7
      Posts
      71
      Views

      Animation, composition, overlaying and whatever comes to your imagination. That said, if you are really only showing one single image and nothing more then, indeed, a QLabel is enough.
    • SOLVED Apply a transformation to all QGraphicsItem in a QGraphicsScene
      General and Desktop • c++ qgraphicsscene qtwidgets qgraphicsitemgr qtransform • • ThThoma  

      5
      0
      Votes
      5
      Posts
      62
      Views

      At the end I've researched again the view's transformations and concluded to support both features and warn for the complexity. I did not re-implement the add/remove items of the scene together with a group. Thanks for the hint @Asperamanca .
    • UNSOLVED rotated qgraphicssceneitem bounding rect
      General and Desktop • qgraphicsscene qgraphicsitem rotation qrect qpolygon • • Loc888  

      3
      0
      Votes
      3
      Posts
      131
      Views

      Hey, not sure if you found the solution yet. But you can try this: QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem; pixmapItem->setPixmap(QPixmap(":/images/pixmap.png")); _scene->addItem(pixmapItem); pixmapItem->setRotation(pixmapItem->rotation() + 45.0); QGraphicsRectItem *boundingRect = new QGraphicsRectItem(pixmapItem->sceneBoundingRect()); QPen outlinePen; outlinePen.setWidth(2); outlinePen.setColor(Qt::red); boundingRect->setPen(outlinePen); _scene->addItem(boundingRect); I believe what you want is the sceneBoundingRect() and not the boundingRect().
    • UNSOLVED Custom coordinate system using QGraphicsView, QGraphicsScene and QGraphicsRectItem
      General and Desktop • qgraphicsview qgraphicsscene coordinate • • HappyVisualizer  

      4
      0
      Votes
      4
      Posts
      218
      Views

      @HappyVisualizer Since your view is in a layout... have you tried to set the layout margin to 0?
    • SOLVED Question about QGraphicsScene and QGraphicsPixmapItem
      General and Desktop • qgraphicsscene mousepressevent qgraphicspixmap mousemoveevent • • CAP 33  

      10
      0
      Votes
      10
      Posts
      328
      Views

      I solved my problem via event filter of scene. ui->graphicsView->scene()->installEventFilter(this); bool MainWindow::eventFilter(QObject* obj, QEvent* event){ if(event->type() == QEvent::GraphicsSceneMousePress){ if(ui->addServerBtn->isChecked()){ QGraphicsSceneMouseEvent* mouseSceneEvent; mouseSceneEvent = static_cast<QGraphicsSceneMouseEvent *>(event); Server *serv = new Server(mouseSceneEvent->scenePos().toPoint()); scene->addItem((QGraphicsPixmapItem*)serv); } } return false; }
    • SOLVED QGraphicsItem set item pos using Cursor
      General and Desktop • qgraphicsview qgraphicsscene qcursor • • Dariusz  

      2
      0
      Votes
      2
      Posts
      118
      Views

      For any1 wondering, its more or less > item->setPos(mNodeViewPtr->mapToScene(mNodeViewPtr->mapFromGlobal(QCursor::pos()))); you can most likely do mNodeViewPtr->viewport()->mapFromGlobal() for more precision I think but I didn't test it.
    • SOLVED Receive Drag/Drop events for items in QGraphicsScene
      General and Desktop • qgraphicsview qgraphicsscene drag and drop event handling • • sticky thermos  

      8
      0
      Votes
      8
      Posts
      305
      Views

      @sticky-thermos said in Receive Drag/Drop events for items in QGraphicsScene: void ChessBoard::mouseMoveEvent(QMouseEvent *event) { std::cout << FUNCTION << std::endl; QGraphicsView::mousePressEvent(event); QDrag *drag = new QDrag(this); QMimeData *mime = new QMimeData; // this is necessary even if nothing is set in the mime data drag->setMimeData(mime); drag->exec(); } Looks good, but I would add a check to differenciate whether your mouseButton is down. Otherwise you are creating a lot of drags from just moving your mouse around on your chessBoard. Also, you are passing the ChessBoard::mouseMoveEvent(QMouseEvent *event) to QGraphicsView::mousePressEvent(event). QGraphicsView::mouseMoveEvent would be more fitting :)
    • SOLVED Add a movable tableview to a qt scene
      General and Desktop • qtableview qgraphicsscene qt widget qt desktop • • sachinrd  

      3
      0
      Votes
      3
      Posts
      153
      Views

      Thanks for the reply @SGaist . This helps
    • UNSOLVED add a textedit widget to a graphics view scene
      General and Desktop • qgraphicsscene textedit graphicsview qt desktop • • sachinrd  

      1
      0
      Votes
      1
      Posts
      165
      Views

      No one has replied

    • SOLVED Animated GIF in QGraphicsScene/QGraphicsView
      General and Desktop • qgraphicsview qgraphicsscene animations gif qmovie • • artwaw  

      8
      0
      Votes
      8
      Posts
      2169
      Views

      @Chris-Kawa Noted thank you. Now it compiles without errors. I think I need to read a bit about newer c++...
    • UNSOLVED Web enabling a desktop app.
      QtWebEngine • qgraphicsscene qpainter web app • • TenG  

      4
      0
      Votes
      4
      Posts
      349
      Views

      @TenG Be aware that not all of Qt modules are supported in WASM. Before anything, check the list at https://doc.qt.io/qt-5/wasm.html#supported-qt-modules against what is in your app. For example, it doesn't do databases, you can't access the local file system, and so on. Also I noticed this time that it requires a Qt static build, but maybe you have to have that for iOS anyway, I don't know. If it works for you it's a really simple solution compared to rewriting anything. Just check out the gotchas.
    • UNSOLVED Pyside6 how to disconnect connection?
      General and Desktop • qgraphicsscene qgraphicsitem signal qobje • • Dariusz  

      34
      0
      Votes
      34
      Posts
      3550
      Views

      I guess I provided inadequate subtext for that example. It's documentation in a project I work on, explaining that qObject.signal.connect(lambda: anotherQObject.function(arg)) is unsafe in PyQt if anotherQObject might be destroyed before qObject. The same would happen in C++ with QObject::connect(qObject, &MyClass::signal, [&]() { anotherQObject->function(arg); }); In C++, one possible solution is to use QObject::Connect(sender, signal, context object, functor). To the best of my knowledge In PyQt5, and I suspect in PySide2/Qt for Python, there is no equivalent. You can write one by taking the connection object returned by object.signal.connect() and using it in a slot connected to anotherQObject.destroyed.
    • UNSOLVED Future of QGraphicsView and QGraphicsScene
      General and Desktop • qgraphicsview qgraphicsscene • • bewi  

      8
      0
      Votes
      8
      Posts
      423
      Views

      @Asperamanca said in Future of QGraphicsView and QGraphicsScene: @jeremy_k said in Future of QGraphicsView and QGraphicsScene: @Asperamanca I think my point was missed. There's no need to choose Quick|Graphics View|Widgets for the entire application. Use each where they make sense and use the underlying Qt core functionality to communicate. Yes, I missed your point. But maybe you missed mine: There is currently no better technology (in Qt) for some use cases than GraphicsView. Of course I can mix and match, depending on what I need. No, I didn't. We're in agreement there. It's easy to look at the graphics silos and forget that they can cooperate.
    • SOLVED QStackedWidget and adding new QGraphicsView to its pages
      General and Desktop • qgraphicsview qgraphicsscene qstackedwidget • • newToQt26  

      7
      0
      Votes
      7
      Posts
      630
      Views

      @newToQt26 Hi Good to hear. :) If the user can add or delete layers, it's pretty important you make sure curScene/curView always points to something valid as else you get a nasty crash.
    • UNSOLVED Is there a way to refresh some part of QGraphicsScene
      General and Desktop • opengl qgraphicsscene • • aminM  

      1
      0
      Votes
      1
      Posts
      246
      Views

      No one has replied

    • SOLVED Removing Widget from QGRaphicsScene without delting it
      General and Desktop • qgraphicsscene remove widget • • gde23  

      4
      0
      Votes
      4
      Posts
      514
      Views

      I currently don't know but since the behaviour is different, I would fill a bug. If it's intended, the documentation should reflect that.
    • UNSOLVED Connect 2 custom movable QGraphicsItems with an auto adjustable multiline
      General and Desktop • qgraphicsscene qgraphicsitem • • ppetukhov  

      1
      0
      Votes
      1
      Posts
      234
      Views

      No one has replied

    • SOLVED Creating a QGraphicsItem in the position of the context menu not positioning properly
      General and Desktop • qgraphicsscene qgraphicsitem • • amansahil  

      6
      0
      Votes
      6
      Posts
      506
      Views

      @amansahil Check after setting the position if polygon->scenePos() - clickPoint == (0, 0). If it is, there's a problem with the event->scenePos(), and if not, there's a problem with how the polygon position is being set. The right conversion would be polygon->setPos( clickPoint - polygonParent->scenePos() ) mapFromScene() is better than mapToScene() since you have the coordinates in the scene frame and you want them in local coordinates. But it still isn't quite right! You specify position in the local parent coordinates, not the local item frame. So that approach to use is polygon->setPos( polygonParent->mapFromScene(clickPoint) )
    • UNSOLVED PySide2: Filling not scaled
      Language Bindings • qgraphicsscene pyside2 scale • • galou_breizh  

      3
      0
      Votes
      3
      Posts
      428
      Views

      @galou_breizh I think point_size is too small and the ellipse generated is "pixelated" because of that. This gives a nice circle filled with blue # -*- coding: utf-8 -*- """Show an incomprehension in setScale for QGraphicsItemGroup.""" from PySide2 import QtCore from PySide2 import QtGui from PySide2 import QtWidgets point_size = 10.0 # In real-world units. # Get entrypoint through which we control underlying Qt framework app = QtWidgets.QApplication([]) scene = QtWidgets.QGraphicsScene() group = QtWidgets.QGraphicsItemGroup() scale = 50.0 # 1 real-world units = 500 px. !! Has no apparent effect. pen = QtGui.QPen(QtCore.Qt.red) brush = QtGui.QBrush(QtCore.Qt.blue) x = 1.0 # Real-world units. y = 2.0 # Real-world units. top_left = (x - point_size / 2.0, y - point_size / 2.0) ellipse = QtWidgets.QGraphicsEllipseItem( QtCore.QRectF(*top_left, point_size, point_size)) ellipse.setPen(pen) ellipse.setBrush(brush) ellipse.setScale(scale) group.addToGroup(ellipse) # group.setScale(scale) scene.addItem(group) view = QtWidgets.QGraphicsView(scene) view.show() # Start Qt/PySide2 application. If we don't show any windows, the # app would just loop at this point without the means to exit app.exec_()
    • UNSOLVED PySide2: Understanding QGraphicsItemGroup.setScale()
      Language Bindings • qgraphicsscene pyside2 scale • • galou_breizh  

      4
      0
      Votes
      4
      Posts
      436
      Views

      @galou_breizh I answered in the other post. But it's not a good way to duplicate post for the same issue. Please try to avoid it in the future, thanks
    • UNSOLVED QGraphicsItem ignores mouse release event when ItemIsMovable is false.
      General and Desktop • qgraphicsview qgraphicsscene qgraphicsitem mouseevent flag • • Forfunckle  

      5
      0
      Votes
      5
      Posts
      362
      Views

      @mrjj Yes, it worked. Thank you!
    • UNSOLVED Resize a rotated GraphicsItem from Center
      General and Desktop • qgraphicsscene qgraphicsitem • • sayan275  

      1
      0
      Votes
      1
      Posts
      157
      Views

      No one has replied

    • UNSOLVED QGraphicsView - custom curve dissapearing when too close
      General and Desktop • qgraphicsview qgraphicsscene qgraphicsitem • • Dariusz  

      3
      0
      Votes
      3
      Posts
      280
      Views

      It appears that QGraphicsScene checks if position of item is visible in view and then draws/dont draws it... returning qgraphicsScene->sceneRect() as boundingRect on my curve "solved" the issues but its a problem for selectable items... hmmm
    • UNSOLVED Arial italic font dont work right on qgraphicsscene
      General and Desktop • qgraphicsscene qgraphicsitem paint fonts • • mehmetkarlik  

      2
      0
      Votes
      2
      Posts
      271
      Views

      Hi, Can you provide a minimal compilable code that shows that behaviour ?
    • UNSOLVED QGraphicsScene - selection signals/new/old/changed?
      General and Desktop • qgraphicsview qgraphicsscene • • Dariusz  

      3
      0
      Votes
      3
      Posts
      355
      Views

      @sgaist Hmmmmmmmmm I wrote a little routine to use mouse press/release to see what has changed to determine my selection but it does not work as well as I wish. But I missed that focusItemChanged mhmhmhmh thanks! Will go over it again :- )
    • SOLVED QGraphicsScene item is drawn at twice(x2) position
      General and Desktop • qgraphicsscene scenepos • • bliako  

      3
      0
      Votes
      3
      Posts
      438
      Views

      I have just figured it out. My first misunderstanding was that the boundingRect()'s coordinates must be (-0.5,-0.5) which means they are relative to the current item's position and not absolute on the Scene. and so this is the correct one: QRectF GIPoint::boundingRect() const { // return QRectF(pos().x(), pos().y(), 5, 5); return QRectF(-0.5, -0.5, 5, 5); } My second misunderstanding was in paint(). Do not use the pos() or scenePos() coordinates in order to draw the item. Instead draw it at (0,0). So the corrected paint() is this: void GIPoint::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ){ (void )option; (void )widget; QRectF rect = boundingRect(); qWarning() << "painting: scenePos " << scenePos() << ", rect " << rect; QBrush brush = QBrush(Qt::black, Qt::SolidPattern); painter->fillRect(rect, brush); //painter->drawRect(rect); } The original program in my question still needs to be modified. Or shall I edit the changes in?
    • UNSOLVED QGraphicsView - background grid - shifts/moves when pan/zooom...
      General and Desktop • qgraphicsview qgraphicsscene • • Dariusz  

      3
      0
      Votes
      3
      Posts
      1045
      Views

      可以参考这个网站进行进行背景图的绘制,缩放的原理 等https://www.desmos.com/calculator?lang=zh-CN 同时参考这这个链接,进行背景绘制https://stackoverflow.com/questions/24728477/infinite-grid-in-qt
    • SOLVED Scale items position relative to the scene/view resizing
      General and Desktop • qt5 qgraphicsview qgraphicsscene qgraphicsitem • • alizadeh91  

      3
      0
      Votes
      3
      Posts
      1355
      Views

      Call fitInView on the GraphicsView with the Image whenever the size of the GraphicsView changes. The rest should work automatically.
    • SOLVED Crop pixmap from qgraphicsscene with qgraphicsItem
      General and Desktop • qgraphicsscene qgraphicsitem qpixmap • • sayan275  

      6
      0
      Votes
      6
      Posts
      1688
      Views

      Hi, I got the expected output from grab(QRect) https://stackoverflow.com/questions/16362191/qt-grab-widget-and-save-image m_graphicsView->grab(rect).save("OUT.jpg"); Thanks all.
    • SOLVED QGraphicsItem select only border
      General and Desktop • qgraphicsview qgraphicsscene qgraphicsitem • • Gianluca86 0  

      4
      0
      Votes
      4
      Posts
      838
      Views

      Thanks @SGaist and @raven-worx , I try both methods to see which one to use better in my program.
    • SOLVED Make QGraphicsItem cover items under it
      General and Desktop • qgraphicsscene qgraphicsitem background graphicsview • • mbise1993  

      6
      0
      Votes
      6
      Posts
      722
      Views

      I found the problem. I was drawing the beats before the lines, so the lines took precedent over the beats since they are siblings. The solution was to either draw the beats last or set the Z value on the beat, not the note.
    • UNSOLVED Restrict resize of a Widget.
      General and Desktop • qgraphicsview qgraphicsscene qt 5.7 qresizeevent resize event • • sayan275  

      6
      0
      Votes
      6
      Posts
      1485
      Views

      The idea is that you have your container widget getting resized and in its resize event, you change the size of the inner widgets with the ratio you want.
    • SOLVED QGraphicsView/Scene paints over other widgets
      General and Desktop • qgraphicsview qgraphicsscene qpainter qpainterpath • • Niagarer  

      11
      0
      Votes
      11
      Posts
      2851
      Views

      @Niagarer Good found. :)
    • SOLVED Creating a pedigree chart
      General and Desktop • qgraphicsview qgraphicsscene qgraphicsitem • • ByronCoughlin  

      7
      0
      Votes
      7
      Posts
      1037
      Views

      @mrjj There are other obstacles that I need to overcome. But this way seems to be the solution that i am implementing. Thanks