QLineEdit cursor issue
Solved
General and Desktop
-
Hi! I added IP mask to the
QLineEdit
, but the cursor on focus is bold.Code:
QLineEdit *lineEdit = new QLinedEdit(this); lineEdit->setClearButtonEnabled(true); lineEdit->setInputMask("000.000.000.000"); lineEdit->setInputMethodHints(Qt::ImhDigitsOnly);
How to make it font normal?
For example:
Thanks.
-
hi, it was done on purpose, you can't change it.
refer to here: https://forum.qt.io/topic/41096/cursor-width-in-qlineedit-when-using-inputmask/4
-
-
So I have decided to remove IP mask and support
IPv6
protocol as well. -
Hi
You can tryclass LineEditStyle : public QProxyStyle { public: LineEditStyle(QStyle *style = 0) : QProxyStyle(style) { } int LineEditStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const { if (metric == QStyle::PM_TextCursorWidth) return 1; return QProxyStyle::pixelMetric(metric,option,widget); // ultra import to return default values for all others } }; then ui->LineEdit-> setStyle(new LineEditStyle(style()));
Not sure a masked will obey it but its worth a shot.
-
you can use a validator instead of a mask