I paint widget QLineEdit through paintEvent() by myself, but the problem is the cursor can't follow the text.
I set the text AlignCenter, and drawText also AlignCenter, but the cursor still think my word is AlignLeft.
painter.drawText(0, 0, button_rect.width(), button_rect.height(), Qt::AlignCenter, text);
QLine cursor(this->cursorRect().x(), this->cursorRect().y(), this->cursorRect().x() , this->cursorRect().y()+ this->cursorRect().height() -1);
painter.setPen(QPen(QBrush(QColor(0,0,0,255)), 3.0));
painter.drawLine(cursor);
here the picture, and the black vertical line is cursor.
Bookmarks