PDA

View Full Version : Why isn’t my QGraphicsTextItem movable? (draggable with mouse)



philw
13th December 2014, 18:12
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).


OcanTextGfxItem::OcanTextGfxItem (TextData* textData,
OutputCanvasScene* gfxScene)
: QGraphicsTextItem (NULL),
_textData (textData), // TextData*, not ownership
_scene (gfxScene) // OutputCanvasScene*
{
setFlags (QGraphicsItem::ItemIsMovable |
QGraphicsItem::ItemIsFocusable |
QGraphicsItem::ItemIsSelectable);

setPlainText (tr ("Test Text"));
setEnabled (true);
setVisible (true);
}

philw
14th December 2014, 01:20
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/pub/TextItem-Zvalue.png

10804

d_stranz
14th December 2014, 17:48
LOL, Chutes and Ladders as a substitute for a topo map.