The QGraphicsTextItem class, part of the Qt framework, provides a text item that you can add to a QGraphicsScene to display formatted text.
Questions tagged [qgraphicstextitem]
64 questions
1
vote
1 answer
Reading Rich Text Character and Block Formatting
I have rich text items implemented using QGraphicsTextItem
To set font size, for example:
void set (int fontSize) {
QTextCursor _cursor = textCursor();
QTextCharFormat _format;
_format.setFontPointSize(fontSize);
…

Thalia
- 13,637
- 22
- 96
- 190
1
vote
1 answer
How to continue text editing after formatting changes of QGraphicsTextItem?
I am trying to make changes (font changes) to a QGraphicsTextItem that is editable.
I am trying to change formatting of fragments of text, or the formatting applied at typing point (if I set text bold, the text I type after that action at cursor…

Thalia
- 13,637
- 22
- 96
- 190
1
vote
2 answers
How can I hide the caret when not in edit mode?
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)
{
…

Thalia
- 13,637
- 22
- 96
- 190
1
vote
1 answer
QGraphicsTextItem editing requires an action performed twice
I want to make a QGraphicsTextItem editable on double click, and make it movable when I click out.
#include
#include
#include
#include
class TextItem: public QGraphicsTextItem
{
public:
…

Thalia
- 13,637
- 22
- 96
- 190
1
vote
2 answers
How can I display unicode in QGraphicsTextItem?
I would like to be able to display Unicode in QGraphicsTextItem (or a subclass of it).
The only way to set text in QGraphicsTextItem seems to be
setPlainText(text);
Trying
setPlainText(QString::fromUtf8("Caf\x00e9…

Thalia
- 13,637
- 22
- 96
- 190
1
vote
0 answers
Qt Transform text
Is there any way to transform QGraphicsTextItem like on the picture (curve it around the circumference).
I found QTransform class which i can apply by using QGraphicsItem::setTransform, but I can't found function to transform text like shown on…

user2160982
- 189
- 1
- 2
- 10
1
vote
1 answer
Cannot implement Drag and Drop for TextItem
this is my first try trying to use Drag&Drop feature of Qt. I'm a beginner, I made my first subclassing this week although I have made other 2 Qt programs in the past.
I need a movable by Drag&Drop QGraphicsTextItem to show on a QGraphicsView that…

user2348235
- 57
- 8
1
vote
1 answer
PyQt4 segmentation fault when assigning text to QGraphicsSimpleTextItem
I'm using Python 2.7.5 on Ubuntu 13.10 and the PyQt4 version is 4.10.2. I'm new to PyQt and the following code demonstrates how I get the segmentation fault.
after starting the python interpreter:
Python 2.7.5+ (default, Sep 19 2013, 13:48:49)
[GCC…

user3126725
- 13
- 2
1
vote
2 answers
PySide: Adding a background color to a QGraphicsTextItem object
Is there a way to add a background color to a QGraphicsTextItem object?
I've created a QGraphicsScene, and need to display text inside it. I've created a QGraphicsTextItem to do the job. However, it's not very clear against the background, so I'm…

midrare
- 2,371
- 28
- 48
0
votes
0 answers
Why QGraphicsSimpleTextItem is "displayed" as QGraphicsItem?
In Qt 6.3.2, this code snippet
QGraphicsSimpleTextItem *test_simple_text = new QGraphicsSimpleTextItem(QStringLiteral("test simple text"));
qDebug() << "*** QGraphicsSimpleTextItem:" << test_simple_text;
gives
*** QGraphicsSimpleTextItem:…

Pamputt
- 173
- 1
- 11
0
votes
1 answer
TextItem scaling in pyqtgraph
I'm having a problem with the font scaling of TextItems in pyqtgraph, like you can see from the following code when I zoom in/zoom out in the main graph the font of the TextItems stays the same while I'm trying to make It scale in the same exact way…

Giorgio
- 61
- 1
- 4
0
votes
1 answer
Resize border of qgraphicstextitem
I am adding a QGraphicTextItem to a scene using pyqt6.
I cannot resize the widget border when text is resized.
I have looked at a few way of resizing, but none work.
The text does change to a bigger font via the context menu.
The entire class is…

Colin Curtain
- 217
- 1
- 10
0
votes
1 answer
Elide the text of a QGraphicsTextItem when it exceeds a defined QRect
I have a QGraphicsTextItem that is a child of a QGraphicsPathItem which draws a box. I want the QGraphicsTextItem to only display text that fits within the box, if it overflows I want that text to be elided.
I've been able to get this working, but…

Adam Sirrelle
- 357
- 8
- 18
0
votes
0 answers
How can I resize a QGraphicsTextItem including its text/contents in PyQt5?
I made a QGraphicsTextItem and set plain text as its content. After that, I set the QGraphicsTextItem inside the QGraphicsWidget.
My question is, Is it possible to resize the QGraphicsTextItem including its text/contents like in this picture:
This…

Eliazar
- 301
- 3
- 13
0
votes
1 answer
Removing QGraphicsSimpleTextItem from QGraphicsView's Scene not working
As part of my pet project, I would need to add & remove text from QGraphicsScene. However for some reason I am unable to remove QGraphicsSimpleTextItems in the same manner as one would remove polygons, namely creating them with a pointer, and using…

usario121233
- 19
- 9