qgraphicstextitem

How can I hide the caret when not in edit mode?

拜拜、爱过 提交于 2020-01-24 20:51:26
问题 I have a TextItem inheriting QGraphicsTextItem . I made it so that on double-click I can edit the text, and when clicking out, the text is no longer editable. void TextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event) { setTextInteractionFlags(Qt::TextEditorInteraction); setFocus(); int p = document()->documentLayout()->hitTest(event->pos(), Qt::FuzzyHit); QTextCursor _cursor = textCursor(); _cursor.setPosition(p); setTextCursor(_cursor); } void TextItem::focusOutEvent(QFocusEvent

QGraphicsSimpleTextItem “invalid use of incomplete type”

寵の児 提交于 2019-12-31 07:16:05
问题 My code is as follows: pointerwidget.h QGraphicsSimpleTextItem *text; pointerwidget.cpp void PointerWidget::placeNumbers(float spacing, int currentTickNumber) { float label = spacing/scaleFactor; text = scene->addSimpleText(QString::number(label),QFont("Comic Sans MS", 12, QFont::Bold)); text->setPos(currentTickNumber*spacing,30); } Everywhere that i read says to use setPos(x,y) to position the text item. This is a function of QGraphicsItem. I get the error of "invalid use of incomplete type

QGraphicsTextItem editing requires an action performed twice

混江龙づ霸主 提交于 2019-12-13 01:56:57
问题 I want to make a QGraphicsTextItem editable on double click, and make it movable when I click out. #include <QApplication> #include <QPainter> #include <QGraphicsItem> #include <QGraphicsView> class TextItem: public QGraphicsTextItem { public: TextItem() { setPlainText("hello world"); QFont f; f.setPointSize(50); f.setBold(true); f.setFamily("Helvetica"); setFont(f); setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsSelectable);

How to make a QGraphicsTextItem clickable?

一曲冷凌霜 提交于 2019-12-11 06:56:05
问题 In the "About box" of my software, I used a QGraphicsTextItem to show the about-text. This text contains hypertext links (in the form of: <a href="http://some.random.site">link</a> ). The item shows up properly (hypertext links are blue and underlined). However, when I click on them, nothing happens. Here is how I created the QGraphicsTextItem : d_about_text_item = new QGraphicsTextItem; d_about_text_item->setTextInteractionFlags(Qt::TextBrowserInteraction); d_about_text_item->setHtml