Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. AddItem where QGraphicsSceneMouseEvent happened
QtWS25 Last Chance

AddItem where QGraphicsSceneMouseEvent happened

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.5k Views
  • 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 Offline
    A Offline
    airglide
    wrote on last edited by
    #1

    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
    0
    • A Offline
      A Offline
      airglide
      wrote on last edited by
      #2

      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
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved