Questions tagged [qgraphicstextitem]

The QGraphicsTextItem class, part of the Qt framework, provides a text item that you can add to a QGraphicsScene to display formatted text.

Documentation can be found here (Qt4) and here (Qt5).

64 questions
0
votes
0 answers

MouseMoveEvent triggers when QGraphicsTextItem is added (even in the condition of hasMouseTracking()==False)

I discovered that when I add QGraphicsTextItem to Scene, MouseMoveEvent Triggered without the mouse button pressed. I checked QgraphicsView.hasMouseTracking() value and it was False in default. It happens only when I add 'TextItem' to Scene and It…
0
votes
1 answer

End Game Function

I'm trying to display "Game Over" once the player runs out of lives. However, it's never displayed after the game ends. Here is some example code. void Game::end() { QGraphicsTextItem *text = new QGraphicsTextItem("GameOver"); text->setPos(400,…
0
votes
1 answer

How to properly position a QGraphicsTextItem on a QGraphicsScene

The probelm I have is that I am trying to position a QGraphicsTextItem on a specific location of my QGraphicsScene , to be precise in the center of the speedometer below. But nothing I tried seems to work properly. Despite I clearly provided the…
Emanuele
  • 2,194
  • 6
  • 32
  • 71
0
votes
1 answer

how to use scene object of main file in other file?

I tried to make tictactoe game using Qt and Qgraphicsview but when I draw x on board using Graphicstextitem in mousePressEvent , X does not appear. how fix that ? I think the problem is that scene of textitem Different from scene of main file but I…
0
votes
1 answer

QGraphicsTextItem mouseDoubleClickEvent

I am a new guy for QT. Now a question confuses me. Code in the MainWindow as follows: MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { QGraphicsView *view = new QGraphicsView; QGraphicsScene *scene =new QGraphicsScene; …
Clifford
  • 1
  • 2
0
votes
1 answer

QGraphicsTextItem: Increasing size equally in both directions (left and right)

Background I'm using QGraphicsTextItem inside a QGraphicsScene and would like to center the text and slowly and smoothly make it larger as time passes. For QGraphicsTextItem there's no setWidth()/setRight() function, instead I use setScale() to…
sunyata
  • 1,843
  • 5
  • 27
  • 41
0
votes
1 answer

QGraphicsSimpleTextItem "invalid use of incomplete type"

My code is as follows: pointerwidget.h QGraphicsSimpleTextItem *text; pointerwidget.cpp void PointerWidget::placeNumbers(float spacing, int currentTickNumber) { float label = spacing/scaleFactor; text =…
0
votes
2 answers

Getting formatting of empty lines

I am a bit confused about how the QTextBlock::iterator works: The documentation shows clear examples of how to use it, on normal text: QTextBlock::iterator it; for (it = currentBlock.begin(); !(it.atEnd()); ++it) { QTextFragment currentFragment…
Thalia
  • 13,637
  • 22
  • 96
  • 190
0
votes
1 answer

Remove/delete/replace selected text in QGraphicsTextItem

I would like to delete the selected text inside a QGraphicsTextItem. I have been searching all the classes it uses - like QTextCursor, QTextDocument... I can't find anything to remove text, except the clear() function of the QTextDocument which…
Thalia
  • 13,637
  • 22
  • 96
  • 190
0
votes
1 answer

How can I get my caret to show up on first double-click action on a QGraphicsTextItem?

I am struggling to get a QGraphicsTextItem to work as a user friendly object. Since it is very hard to move while being editable, I start it as not editable, and make it editable on double-click. Then turn editing off on losing focus. My problem…
Thalia
  • 13,637
  • 22
  • 96
  • 190
0
votes
1 answer

QGraphicsSceneTextItem delete old text

What I want to do is to delete or update the text value of the QGraphicsSimpleTextItem that i added to a QGraphicsItem,but for a certain cause the text do not update but it's acumulated in the item created.this is what i have done for now : void…
0
votes
1 answer

Text field keeping track of count in QT using QGraphicsScene

I have a QT-project (using C++) where instances of a certain user-defined QGraphicsItem called Person move around the scene. Sometimes those Persons interact so that some of them change color. Now I want to put a text field in the window and display…
String
  • 207
  • 1
  • 2
  • 8
0
votes
0 answers

How to fix the position of QGraphicsItem and making only the QGraphicsTextItem to move?

I have a QGraphicsView in which I am painting a QGraphicsItem and QGraphicsTextItem. I have set the flag ItemIsMovable for the QGraphicsTextItem for editing the long text. Here my concern. When I am moving the QGraphicsTextItem to view the long…
Bharathi
  • 337
  • 1
  • 5
  • 17
0
votes
1 answer

How to remove the focus of a QGraphicsTextItem from a main QWidget

I have a number of QGraphicsTextItem and QGraphicsItem painted inside a QGraphicsView. This QGraphicsView has been added to the main Qwidget. I have written the "FocusOutEvent" for this QGraphicsTextItem and the focus is getting removed only when…
Bharathi
  • 337
  • 1
  • 5
  • 17
0
votes
2 answers

QGraphicsTextItem inheritance. Strange behaviour

I created a class, inherited from QGraphicsTextItem. Object of this class must be movable and must send signal when MouseButton is up. class MyTextItem: public QObject, public QGraphicsTextItem { Q_OBJECT public: MyTextItem(QObject* Object,…
Ilya
  • 311
  • 3
  • 18