Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    AddItem where QGraphicsSceneMouseEvent happened

    General and Desktop
    1
    2
    1388
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      airglide last edited by

      hello everyone,

      I want to add an Item if a mouseclick happens, the event works

      @void Board::mousePressEvent(QGraphicsSceneMouseEvent *event)
      {
      //board inheritates from QGrapicsScene
      }@

      I can get the coordinates of the event with event.scenePos(), but if I create a new Item and write addItem() and setPosition( Pos of event) I have strange behavior. If I click on the view, it is always inserted in the middle...
      the coordinates are correct, I've checked that with qDebug...

      I found "Your text to link here...":http://stackoverflow.com/questions/7761442/qgraphicsitem-setpos-is-not-moving-items-position
      but could really figure out what I have to do or why this happens

      thx;)
      airglide

      1 Reply Last reply Reply Quote 0
      • A
        airglide last edited by

        I've found the answer to my problem

        "Answer":http://qt-project.org/forums/viewthread/5735

        but if I setSceneRect(), I've got the problem, that the Scene has a limited size and no scrollbars.. how can I change that? someone a smart idea?

        thx airglide

        1 Reply Last reply Reply Quote 0
        • First post
          Last post