Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QLineEdit cursor issue
Forum Updated to NodeBB v4.3 + New Features

QLineEdit cursor issue

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.0k Views 2 Watching
  • 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.
  • C Offline
    C Offline
    Cobra91151
    wrote on 28 Jan 2018, 17:57 last edited by
    #1

    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
    0
    • U Offline
      U Offline
      user4592357
      wrote on 28 Jan 2018, 18:30 last edited by
      #2

      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

      C 1 Reply Last reply 28 Jan 2018, 18:50
      1
      • U user4592357
        28 Jan 2018, 18:30

        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

        C Offline
        C Offline
        Cobra91151
        wrote on 28 Jan 2018, 18:50 last edited by Cobra91151
        #3

        @user4592357

        Ok. So how Windows makes it to normal then?

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

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Cobra91151
          wrote on 28 Jan 2018, 19:40 last edited by
          #4

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

          U 1 Reply Last reply 28 Jan 2018, 20:15
          0
          • M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 28 Jan 2018, 19:41 last edited by mrjj
            #5

            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
            1
            • C Cobra91151
              28 Jan 2018, 19:40

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

              U Offline
              U Offline
              user4592357
              wrote on 28 Jan 2018, 20:15 last edited by
              #6

              @Cobra91151

              you can use a validator instead of a mask

              1 Reply Last reply
              1

              2/6

              28 Jan 2018, 18:30

              topic:navigator.unread, 4
              • Login

              • Login or register to search.
              2 out of 6
              • First post
                2/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved