I paint a cursor in my textedit ,but it not flash,how can i make the cursor flash?
{
int leading = fm.leading();
int height = 0;
qreal widthUsed = 0;
textLayout.beginLayout();
while (1) {
if (!line.isValid())
break;
line.setLineWidth(200);
height += leading;
line.
setPosition(QPoint(0, height
));
height += (int) line.height();
widthUsed = qMax(widthUsed, line.naturalTextWidth());
textLayout.drawCursor(&p,t,2,3);
}
}
void MYTextEdit:: paintEvent(QPaintEvent *event)
{
QPainter p(viewport());
QTextLayout textLayout(document()->toPlainText());
QPointF t(100,100);
int leading = fm.leading();
int height = 0;
qreal widthUsed = 0;
textLayout.beginLayout();
while (1) {
QTextLine line = textLayout.createLine();
if (!line.isValid())
break;
line.setLineWidth(200);
height += leading;
line.setPosition(QPoint(0, height));
height += (int) line.height();
widthUsed = qMax(widthUsed, line.naturalTextWidth());
textLayout.drawCursor(&p,t,2,3);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks