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 with constant text and editable text fields
Forum Updated to NodeBB v4.3 + New Features

QlineEdit with constant text and editable text fields

Scheduled Pinned Locked Moved Unsolved General and Desktop
widgetline editqt 5.4.2
13 Posts 5 Posters 8.2k 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 Embitel_qt
    14 Nov 2015, 15:33

    Thanks a lot for the example.

    But this solution using QLabel & QLineEdit will not suit my usecase.
    The content text of this LineEdit will be used as file name after replacing placeholder <COUNTER> with values from 0..N.

    M Offline
    M Offline
    mrjj
    Lifetime Qt Champion
    wrote on 14 Nov 2015, 17:05 last edited by
    #4

    @Embitel_qt
    Hi can I ask what is wrong with it ?
    Just to understand.
    It would be easy to create function to return a QString containing
    edit + Label text.

    1 Reply Last reply
    0
    • E Offline
      E Offline
      Embitel_qt
      wrote on 15 Nov 2015, 03:48 last edited by
      #5

      This above mentioned is only one use case. The actual functionality of my LineEdit will contain multiple placeholder fields like <DATE>, <TIME>, etc... which can be added to the LineEdit on the current cursor position.

      So its not an option to use combination of QLineEdit & QLabel.

      M 1 Reply Last reply 15 Nov 2015, 09:56
      0
      • E Embitel_qt
        14 Nov 2015, 14:27

        I have a requirement to have a line edit which has a custom text which is non editable and another field where user can enter new text.
        Please refer the attached image. custom line edit


        | Image_<COUNTER> |

        In that image we can see that the "<COUNTER>" part should be non editable and should always be at the last position. And "Image_" is an editable text where user can enter any text.

        Is there any way to have a custom LineEdit like this.

        R Offline
        R Offline
        RobertoDuran
        wrote on 15 Nov 2015, 06:33 last edited by
        #6

        @Embitel_qt Will hiding the "<COUNTER>" piece of text in the code and having only a LineEdit be satisfactory? I mean storing QLineEdit as a string and adding <COUNTER> to it in code.

        1 Reply Last reply
        0
        • E Embitel_qt
          15 Nov 2015, 03:48

          This above mentioned is only one use case. The actual functionality of my LineEdit will contain multiple placeholder fields like <DATE>, <TIME>, etc... which can be added to the LineEdit on the current cursor position.

          So its not an option to use combination of QLineEdit & QLabel.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 15 Nov 2015, 09:56 last edited by
          #7

          @Embitel_qt
          ah, so <X> can appear anywhere in the text
          and after insertion, should not be editable?
          So you need to support all cases of
          <X>aaaaa
          aaaa<X>aaaa
          aaaa<X>

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 15 Nov 2015, 21:26 last edited by
            #8

            Hi,

            To add to @mrjj do you mean something like Qt Creator's Default build directory settings in Build & Run -> General ?

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

            1 Reply Last reply
            0
            • E Offline
              E Offline
              Embitel_qt
              wrote on 16 Nov 2015, 04:27 last edited by
              #9

              @mrjj yes you are correct <X> can be added at any position in one usecase.

              In my first use case [mode one] there will be only <COUNTER> and this should be always at the end of the LineEdit and which should not be edited. But the user can insert new characters before <COUNTER>

              In my second use case[mode two] there can be any place holder[<CONTER>, <DATE>, <TIME>, etc...] all this can be editable[no restrictions] and user can insert new characters anywhere in the LineEdit.

              1 Reply Last reply
              0
              • H Offline
                H Offline
                Hamed.Masafi
                wrote on 16 Nov 2015, 06:48 last edited by
                #10
                lineEdit->setInputMask("Im\\age\\_0000");
                

                Remote object sharing (OO RPC)
                http://forum.qt.io/topic/60680/remote-object-sharing-oo-rpc-solved

                Advanced, Powerful and easy to use ORM for Qt5
                https://forum.qt.io/topic/67417/advanced-powerful-and-easy-to-use-orm-for-qt5

                1 Reply Last reply
                0
                • E Offline
                  E Offline
                  Embitel_qt
                  wrote on 17 Nov 2015, 12:31 last edited by
                  #11

                  Thnaks for the inputs.
                  Now I have found a way to make my <COUNTER> non editable using the mask

                  lineEdit->setInputMask("xxxx\<\C\O\U\N\T\E\R\>");

                  Now thw problem is I am able to enter only 4 characters before <COUNTER> but i want to allow the user to enter maximum of 91 charcters.

                  What should I modify on the reg expression to achieve this?

                  R 1 Reply Last reply 19 Nov 2015, 07:03
                  0
                  • E Embitel_qt
                    17 Nov 2015, 12:31

                    Thnaks for the inputs.
                    Now I have found a way to make my <COUNTER> non editable using the mask

                    lineEdit->setInputMask("xxxx\<\C\O\U\N\T\E\R\>");

                    Now thw problem is I am able to enter only 4 characters before <COUNTER> but i want to allow the user to enter maximum of 91 charcters.

                    What should I modify on the reg expression to achieve this?

                    R Offline
                    R Offline
                    RobertoDuran
                    wrote on 19 Nov 2015, 07:03 last edited by
                    #12

                    @Embitel_qt Could you not just use 91 "x"s?

                    lineEdit->setInputMask("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1<\C\O\U\N\T\E\R>");

                    M 1 Reply Last reply 19 Nov 2015, 07:22
                    0
                    • R RobertoDuran
                      19 Nov 2015, 07:03

                      @Embitel_qt Could you not just use 91 "x"s?

                      lineEdit->setInputMask("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1<\C\O\U\N\T\E\R>");

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 19 Nov 2015, 07:22 last edited by mrjj
                      #13

                      might be slightly more compact to use the fill method. :)

                      http://doc.qt.io/qt-5/qstring.html#fill

                      1 Reply Last reply
                      0

                      13/13

                      19 Nov 2015, 07:22

                      • Login

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