Results 1 to 3 of 3

Thread: Why isn’t my QGraphicsTextItem movable? (draggable with mouse)

  1. #1
    Join Date
    Jun 2008
    Location
    Boulder, Colorado, USA
    Posts
    70
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Why isn’t my QGraphicsTextItem movable? (draggable with mouse)

    My QGraphicsTextItems (subclass) do show a selection ornamentation. But the user can't move them by dragging with the mouse. What am I missing? (This is with Qt 4.8.5 on Windows 7, 64 bit). Below are the relevant QGraphicsTextItem calls made from by subclass constructor. (I've also tried doing these things after the item is inserted into the scene).

    Qt Code:
    1. OcanTextGfxItem::OcanTextGfxItem (TextData* textData,
    2. OutputCanvasScene* gfxScene)
    3. _textData (textData), // TextData*, not ownership
    4. _scene (gfxScene) // OutputCanvasScene*
    5. {
    6. setFlags (QGraphicsItem::ItemIsMovable |
    7. QGraphicsItem::ItemIsFocusable |
    8. QGraphicsItem::ItemIsSelectable);
    9.  
    10. setPlainText (tr ("Test Text"));
    11. setEnabled (true);
    12. setVisible (true);
    13. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jun 2008
    Location
    Boulder, Colorado, USA
    Posts
    70
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default SOLVED: Why isn’t my QGraphicsTextItem movable? (draggable with mouse): "Z" Value.

    SOLVED -- "Z" Value. The problem was that a large mostly-transparent QGraphicsPixmapItem (image) -- used as a background image -- was getting in the way of my QGraphicsTextItems. I had forgotten to set the "Z" value of those text items [with QGraphicsItem::setZValue (qreal z)]. This prevented the mouse from being able to drag (move) the text item.

    See the accompanying image ... notice the text item in the bottom left ... and the mostly transparent image (chutes and ladders) ... http://cadswes2.colorado.edu/~philw/...tem-Zvalue.png

    TextItem-Zvalue.jpg

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: SOLVED: Why isn’t my QGraphicsTextItem movable? (draggable with mouse): "Z" Value

    LOL, Chutes and Ladders as a substitute for a topo map.

Similar Threads

  1. Replies: 0
    Last Post: 14th February 2012, 11:03
  2. Word at mouse click position in QGraphicsTextItem
    By pherthyl in forum Qt Programming
    Replies: 2
    Last Post: 3rd November 2008, 04:56
  3. Mouse events in QGraphicsPixmapItem and QGraphicsTextItem
    By manojmka in forum Qt Programming
    Replies: 3
    Last Post: 8th August 2008, 11:38
  4. QGraphicsTextItem bug on mouse interaction?
    By mooreaa in forum Qt Programming
    Replies: 3
    Last Post: 4th July 2008, 07:29
  5. [Solved] Selecting text with mouse in a QGraphicsTextItem
    By pherthyl in forum Qt Programming
    Replies: 2
    Last Post: 11th August 2007, 19:10

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.