Home > other >  QGraphicsTextItem editable state
QGraphicsTextItem editable state

Time:04-04

Diagramscene demo in this example, select the TEXT button, click the graphicsview can enter TEXT, when click into editable state, the code is as follows: void Scene: : mouseDoubleClickEvent (QGraphicsSceneMouseEvent * event) {textItem=new DiagramTextItem; TextItem - & gt; SetTextInteractionFlags (Qt: : TextEditorInteraction); TextItem - & gt; SetZValue (1000.0); AddItem (textItem); TextItem - & gt; SetPos (event - & gt; ScenePos ()); QGraphicsScene: : mouseDoubleClickEvent (event); } if commented QGraphicsScene: : mouseDoubleClickEvent (event); Click the view will not be able to enter the editable state, I want to achieve function is within a QGraphicsItem double-click will generate an editable TextItem and into the state, but TextItem into editable status code is as follows: void Node: : mouseDoubleClickEvent (QGraphicsSceneMouseEvent * event) {TextItem=new DiagramTextItem; TextItem - & gt; DRGDDF setPlainText (" "); TextItem - & gt; SetTextInteractionFlags (Qt: : TextEditorInteraction); TextItem - & gt; SetZValue (1000.0); Scene () - & gt; AddItem (textItem); TextItem - & gt; SetPos (event - & gt; ScenePos ()); TextItem - & gt; TextInteractionFlags (); QGraphicsItem: : mouseDoubleClickEvent (event); } if let QGraphicsScene doubleclick events, corresponding QGraphiceTextItem to get into editable state, if QGraphicsItem corresponding, will not be able to enter, but it has been a TextInteractionFlags Qt: : TextEditorInteraction, I mean the editable state refers to the first produce textitem editable in and tested for half a day also can not find the problem, which students aware of the original?

CodePudding user response:

I have seen this example, I am a bool is added in the button st=UI - & gt; TextButton - & gt; IsChecked (); Only can edit button is selected
  • Related