#include "cgTextItem.h"
#include <QPlainTextDocumentLayout>
{
newFont.setPointSize(24);
setFont(newFont);
setDefaultTextColor(Qt::blue);
QPlainTextDocumentLayout *plainLayout = new QPlainTextDocumentLayout(document());
plainLayout->setCursorWidth(100);
document()->setDocumentLayout(plainLayout);
setTextInteractionFlags(Qt::TextEditorInteraction);
setPlainText("New Item");
}
#include "cgTextItem.h"
#include <QPlainTextDocumentLayout>
cgTextItem::cgTextItem(QGraphicsItem *parent, QGraphicsScene *scene)
:QGraphicsTextItem(parent, scene)
{
QFont newFont = font();
newFont.setPointSize(24);
setFont(newFont);
setDefaultTextColor(Qt::blue);
QPlainTextDocumentLayout *plainLayout = new QPlainTextDocumentLayout(document());
plainLayout->setCursorWidth(100);
document()->setDocumentLayout(plainLayout);
setFlag(QGraphicsItem::ItemIsMovable,true);
setFlag(QGraphicsItem::ItemIsSelectable,true);
setTextInteractionFlags(Qt::TextEditorInteraction);
setPlainText("New Item");
}
To copy to clipboard, switch view to plain text mode
this is my construct function ,the QPlainTextDocumentLayout have a function setCursorWidth can be change the cursor width in the QGraphicsTextItem ,
but the effect is not good,it becomed very small. I don't know the reason .can you help me ?
And changed the setCursorWidth's value ,the effect is still .
Bookmarks