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
QtWS25 Last Chance

QLineEdit cursor issue

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.0k Views
  • 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.
  • Cobra91151C Offline
    Cobra91151C Offline
    Cobra91151
    wrote on 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 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

      Cobra91151C 1 Reply Last reply
      1
      • U user4592357

        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

        Cobra91151C Offline
        Cobra91151C Offline
        Cobra91151
        wrote on 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
        • Cobra91151C Offline
          Cobra91151C Offline
          Cobra91151
          wrote on last edited by
          #4

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

          U 1 Reply Last reply
          0
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on 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
            • Cobra91151C Cobra91151

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

              U Offline
              U Offline
              user4592357
              wrote on last edited by
              #6

              @Cobra91151

              you can use a validator instead of a mask

              1 Reply Last reply
              1

              • Login

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