Navigation

    Qt Forum

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

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

      8
      0
      Votes
      8
      Posts
      41
      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
      41
      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
      198
      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
      79
      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
      124
      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
      58
      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
      115
      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
      44
      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
      143
      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
      175
      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
      180
      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
      76
      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
      57
      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
      119
      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
      91
      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
      159
      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
      205
      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  

      2
      0
      Votes
      2
      Posts
      460
      Views

      I've updated the question with gif/some updates... Still fighting with it o.o I think by using int vertOffset = horizontalScrollBar()->sliderPosition(); I can somehow calculate the "jump" value offset and offset position of line by that. Not sure how yet tho...
    • SOLVED Scale items position relative to the scene/view resizing
      General and Desktop • qt5 qgraphicsview qgraphicsscene qgraphicsitem • • alizadeh91  

      3
      0
      Votes
      3
      Posts
      498
      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
      810
      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
      474
      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
      382
      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
      884
      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
      1814
      Views

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

      7
      0
      Votes
      7
      Posts
      765
      Views

      @mrjj There are other obstacles that I need to overcome. But this way seems to be the solution that i am implementing. Thanks
    • SOLVED Change QGraphicsTextItem edit trigger from single click to double click
      General and Desktop • qgraphicsscene qtcharts • • martonmiklos  

      3
      0
      Votes
      3
      Posts
      701
      Views

      @SGaist Hi Sam, Thank you for your hint, but my first problem was preventing the edit trigger on single click. For the posterity I have ended up with the following solution: Disable the textInteraction flags by default Override the QGraphicsTextItem::sceneEvent with the following: bool ValueAxisLabel::sceneEvent(QEvent *event) { if (event->type() == QEvent::GraphicsSceneMouseDoubleClick) { setTextInteractionFlags(Qt::TextEditorInteraction); bool ret = QGraphicsTextItem::sceneEvent(event); // QGraphicsTextItem::sceneevent needs to be processed before // the focus setFocus(Qt::MouseFocusReason); return ret; } return QGraphicsTextItem::sceneEvent(event); } The textInteractionFlags should be disabled in the overridden focusOutEvent.
    • UNSOLVED How can I use QPainter to paint on QGraphicsView?
      General and Desktop • qgraphicsview qgraphicsscene qpainter draw objects • • elmLiu  

      9
      0
      Votes
      9
      Posts
      8366
      Views

      In your MyView::paintEvent write QPainter painter(viewport()); instead of QPainter painter(this);.
    • UNSOLVED Manual resizing of QGraphicsItem using mouse
      General and Desktop • qgraphicsview qgraphicsscene qgraphicsitem resize mouse event • • hellozee  

      1
      0
      Votes
      1
      Posts
      554
      Views

      No one has replied

    • SOLVED Remove QGraphicsTextItem from QGraphicsScene
      General and Desktop • qgraphicsscene remove qgraphicstextit textitem • • AdrianCruz  

      7
      0
      Votes
      7
      Posts
      1069
      Views

      @AdrianCruz hi Super :) just as a note To avoid getting possible NULLs in the list, i would suggest doing QGraphicsItem *item = qgraphicsitem_cast<QGraphicsItem*>(text); if (item) list.push_back(item);
    • UNSOLVED Fit image in QGraphicsView and QGraphicsScene
      General and Desktop • qgraphicsview qgraphicsscene picture • • AdrianCruz  

      2
      0
      Votes
      2
      Posts
      1646
      Views

      Hi, You shouldn't use the size of a widget in its own constructor. The widget being not yet visible, the value won't make sense.
    • UNSOLVED QGraphicsRectItem coordinate system on image resize
      General and Desktop • qgraphicsscene qgraphicsitem resize mapto • • sayan275  

      3
      0
      Votes
      3
      Posts
      615
      Views

      @raven-worx I tried the following but didn't work out.. QGraphicsPixmapItem* item = new QGraphicsPixmapItem(QPixmap::fromImage(qImage, Qt::AutoColor)); m_ViewerScene->addItem(item); QGraphicsRectItem* rect = new QGraphicsRectItem(m_BoundingBox); m_ViewerScene->addItem(rect); rect->setParentItem(item); m_ViewerScene->update(); //add the resized QGraphicsPixmapItem to the pixmap item->setPixmap( item->pixmap().scaled(QSize(128, 32),Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); qInfo()<<"Rect resize props:::"<<item->childItems()[0]->boundingRect(); m_BoundingBox = item->childItems()[0]->boundingRect(); later I'm drawing box, on the image in an other viewer, with m_BoundingBox. The grey area within the blue rectangle will be resized to 128 * 32, and then the red rectangle would be added on the resized image. How to get the co-ordinates of red rect on the resized image?
    • UNSOLVED Reuse a QGraphicsScene causes memory leak
      General and Desktop • qgraphicsscene memory leak • • wthung  

      2
      0
      Votes
      2
      Posts
      446
      Views

      Hi @wthung, I don't think this forum supports file uploads. Can you create a simple example that demonstrates the memory leak? Just post the code here, no need to upload an attachment.
    • SOLVED Crash in QGraphicsScene::event when removing and deleting items that use SceneEventFilters
      General and Desktop • qgraphicsscene eventfilter deletelater removeitem • • JEllery  

      6
      0
      Votes
      6
      Posts
      3488
      Views

      @JEllery Thanks so much for solving this. It seems to solve my deletion-crash issue as well. :)
    • UNSOLVED QT, repaint line that doesn't have boundingRect()
      General and Desktop • qgraphicsscene qt4 boundingrect python2 shape • • helloworld12345  

      2
      0
      Votes
      2
      Posts
      540
      Views

      Hi I just keep a pointer to the "white lines" and adjust if i move yellow. class ColorItem : public QGraphicsItem { .. ConnectorLine* line = nullptr; .. protected: QVariant itemChange(GraphicsItemChange change, const QVariant& value) override { if (change == ItemPositionChange && scene()) { if (line) { line->adjust(); } } return QGraphicsItem::itemChange(change, value); } private: QColor color; }; line->Adjust() alters its endpoints. You could just adjust it directly here.
    • SOLVED How to swap QGraphicsRectItems on scene(changing theirs position)
      General and Desktop • qgraphicsscene qgraphicsrectit swap change position get position • • lete  

      4
      0
      Votes
      4
      Posts
      753
      Views

      You're welcome ! Since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)
    • UNSOLVED How to create a menu using GraphicsScene with buttons
      Mobile and Embedded • qgraphicsscene qgraphicsitem menu • • mounipanditi  

      1
      0
      Votes
      1
      Posts
      443
      Views

      No one has replied