Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Solved QLineEdit cursor issue

    General and Desktop
    3
    6
    704
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Cobra91151
      Cobra91151 last edited by

      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);
      

      0_1517162015672_2018-01-28_190748.png

      How to make it font normal?

      For example:
      0_1517162257941_2018-01-28_195657.png

      Thanks.

      1 Reply Last reply Reply Quote 0
      • U
        user4592357 last edited by

        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

        Cobra91151 1 Reply Last reply Reply Quote 1
        • Cobra91151
          Cobra91151 @user4592357 last edited by Cobra91151

          @user4592357

          Ok. So how Windows makes it to normal then?

          For example:
          0_1517162257941_2018-01-28_195657.png

          1 Reply Last reply Reply Quote 0
          • Cobra91151
            Cobra91151 last edited by

            So I have decided to remove IP mask and support IPv6 protocol as well.

            U 1 Reply Last reply Reply Quote 0
            • mrjj
              mrjj Lifetime Qt Champion last edited by mrjj

              Hi
              You can try

              class 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.

              1 Reply Last reply Reply Quote 1
              • U
                user4592357 @Cobra91151 last edited by

                @Cobra91151

                you can use a validator instead of a mask

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post