Skip to content

QtWS: Super Early Bird Tickets Available!

  • 0 Votes
    3 Posts
    526 Views
    cerrC

    @SGaist said in 'str' object has no attribute 'chop':

    Hi,

    You write your code as if you where using QString objects. With either PySide2 or PyQt5 you'll have Python str objects. You need to translate these bits.

    rrrrrrright, Duh!
    I'm still kind of new to writing Qt in Python...
    changing my code to using pin[:-1] works as expected! Thanks!

  • 0 Votes
    4 Posts
    2k Views
    A

    @Rguessford I would also be interested to get the Qt Creator Debug button to work for both, Python and QML debugging, at the same time. Even with QQmlDebuggingEnabler instantiated.
    I think, I'm stuck at the same as @Jeff-B-0

  • 0 Votes
    2 Posts
    877 Views
    mrjjM

    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.

  • 0 Votes
    2 Posts
    3k Views
    Chris KawaC

    It would be nice to say what self and event are. I'm guessing a QGraphicsItem and a parameter of QGraphicsSceneMouseEvent? Is that right?

    If so then event.pos() and event.scenePos() are not exchangeable. The first one is cursor position in item's coordinates and the second one cursor position in scene coordinates. They are the same only when item is placed at (0,0). If item is moved they will differ. It's important to note that these values are what they were at the time the event took place, which might be different from the "current" values for item (this is a good thing). For example if you move your mouse fast and there are a lot of events generated the cursor position in these events will be a little behind the actual current position of the cursor before they "catch up".

    As for self.scenePos() - this is the position of the item in the scene. This is the point relative to which the event.pos() is calculated. It is not necessary the top left of the bounding rect. It can be placed anywhere using 'setTransformOriginPoint()'. It is often set to the center of the item. For example if you have a bunch of draggable circles a center is probably more convenient than a top left corner. For vertical bars on a chart the origin might be placed at the middle bottom of a bar etc.

  • 0 Votes
    4 Posts
    2k Views
    H

    @jsulm When the pop up Message Box shows "python has stopped working", I clicked "debug" rather than close, then visual studio was started, in visual studio,
    it shows
    Unhandled exception at 0x0000000059A17DF1 (QtGui4.dll) in python.exe: 0xC000041D: An unhandled exception was encountered during a user
    callback

    I was using pycharm to trace code step by step, however it nev, aer run to this issue by step by step since there are two many small steps/callback/signal/slot to go through, as long as I let it run without breakpoint, it will crash with segmentation fault.