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. line edit
Qt 6.11 is out! See what's new in the release blog

line edit

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 6 Posters 2.1k 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.
  • E Offline
    E Offline
    Emre MUTLU
    wrote on last edited by
    #6

    Do you want to separate by dots ? or value ? i don't get this

    M 1 Reply Last reply
    0
    • E Emre MUTLU

      Do you want to separate by dots ? or value ? i don't get this

      M Offline
      M Offline
      muhammed hayr
      wrote on last edited by
      #7

      @Emre-MUTLU
      I want only one point to be entered
      I want it to give an error even though more than one point is entered

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Emre MUTLU
        wrote on last edited by
        #8

        There are better ways but this came to mind.

        QString str=ui->lineEdit->Text();
        QStringList list;
        for(int i=0;i<ui->lineEdit->Text().Length();i++)
        {
        list=str.split(".");
        }
        if(list.Length()>2)
        {
        qDebug()<<" more than one point is entered";
        }
        
        qwasder85Q E 2 Replies Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #9

          Hi,

          Why not use a QDoubleSpinBox for your number input ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply
          1
          • SGaistS SGaist

            Hi,

            Why not use a QDoubleSpinBox for your number input ?

            M Offline
            M Offline
            muhammed hayr
            wrote on last edited by
            #10

            @SGaist
            can you give an example

            jsulmJ 1 Reply Last reply
            0
            • M muhammed hayr

              @SGaist
              can you give an example

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #11

              @muhammed-hayr If you open the link @SGaist gave you you will find a link "Spin Boxes Example"...

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              M 1 Reply Last reply
              1
              • jsulmJ jsulm

                @muhammed-hayr If you open the link @SGaist gave you you will find a link "Spin Boxes Example"...

                M Offline
                M Offline
                muhammed hayr
                wrote on last edited by
                #12

                @jsulm
                I am using numpad

                jsulmJ 1 Reply Last reply
                0
                • M muhammed hayr

                  @jsulm
                  I am using numpad

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #13

                  @muhammed-hayr said in line edit:

                  I am using numpad

                  ?

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1
                  • E Emre MUTLU

                    There are better ways but this came to mind.

                    QString str=ui->lineEdit->Text();
                    QStringList list;
                    for(int i=0;i<ui->lineEdit->Text().Length();i++)
                    {
                    list=str.split(".");
                    }
                    if(list.Length()>2)
                    {
                    qDebug()<<" more than one point is entered";
                    }
                    
                    qwasder85Q Offline
                    qwasder85Q Offline
                    qwasder85
                    wrote on last edited by qwasder85
                    #14

                    @Emre-MUTLU Why the loop?

                    Shorter version:

                    QString text = myLineEdit.text();
                    
                    if (2 < text.split('.', Qt::KeepEmptyParts).length())
                        // Display your warning
                    

                    The cleaner way would be a RegEx validator in my opinion. Although this here should work and would be way less effort, haha.

                    1 Reply Last reply
                    0
                    • E Emre MUTLU

                      There are better ways but this came to mind.

                      QString str=ui->lineEdit->Text();
                      QStringList list;
                      for(int i=0;i<ui->lineEdit->Text().Length();i++)
                      {
                      list=str.split(".");
                      }
                      if(list.Length()>2)
                      {
                      qDebug()<<" more than one point is entered";
                      }
                      
                      E Offline
                      E Offline
                      Emre MUTLU
                      wrote on last edited by
                      #15

                      @Emre-MUTLU said in line edit:

                      There are better ways but this came to mind.
                      ?

                      1 Reply Last reply
                      0

                      • Login

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