From caeafb77fb9ed2fb1c7a8afd5fd15dc8fe8de943 Mon Sep 17 00:00:00 2001 From: Denes Matetelki Date: Mon, 13 Jun 2011 17:05:03 +0200 Subject: [PATCH] new node is created with empty string, when entering node editing mode, the cursor is to the end of the text --- graphwidget.cpp | 2 +- node.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/graphwidget.cpp b/graphwidget.cpp index 11ee2b0..5325b4b 100644 --- a/graphwidget.cpp +++ b/graphwidget.cpp @@ -384,7 +384,7 @@ void GraphWidget::insertNode() QPointF pos(length * cos(angle), length * sin(angle)); Node *node = new Node(this); - node->setHtml(QString("new node")); + node->setHtml(QString("")); m_scene->addItem(node); node->setPos(m_activeNode->sceneBoundingRect().center() + pos - diff --git a/node.cpp b/node.cpp index 57da608..4f8c0b2 100644 --- a/node.cpp +++ b/node.cpp @@ -226,6 +226,10 @@ void Node::setEditable(const bool &editable) editable ? Qt::TextEditable : Qt::NoTextInteraction); + + QTextCursor c = textCursor(); + c.setPosition(c.document()->toPlainText().length()); + setTextCursor(c); } void Node::keyPressEvent(QKeyEvent *event)