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. How to edit text in line edit when echo mode is ON.

How to edit text in line edit when echo mode is ON.

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 1.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.
  • A Offline
    A Offline
    Alam
    wrote on last edited by
    #1

    Hi,
    I am new to QT, I was thinking is it possible to edit some text into line edit when echo mode is ON. what i mean is line edit should not take inputs from the user but should display text when i write to it.

    Pl45m4P jsulmJ 2 Replies Last reply
    0
    • A Alam

      Hi,
      I am new to QT, I was thinking is it possible to edit some text into line edit when echo mode is ON. what i mean is line edit should not take inputs from the user but should display text when i write to it.

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @Alam

      You mean, your LineEdit is a password input, everything the user types should be shown as dots, but the LineEdit should still show plain text to the user?!

      Have you tried "myLineedit->setText(TEXT);"
      Idk if it's working out of the box, otherwise switch echo mode off, show text and turn it on again.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      A 1 Reply Last reply
      1
      • A Alam

        Hi,
        I am new to QT, I was thinking is it possible to edit some text into line edit when echo mode is ON. what i mean is line edit should not take inputs from the user but should display text when i write to it.

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

        @Alam said in How to edit text in line edit when echo mode is ON.:

        what i mean is line edit should not take inputs from the user but should display text when i write to it

        This is not clear to me: what do you mean by "when i write to it"? Do you mean user edits it or do you mean you want to set the text in code? First one does not make sense, the second one is easy (see what @Pl45m4 wrote).

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

        A 1 Reply Last reply
        1
        • Pl45m4P Pl45m4

          @Alam

          You mean, your LineEdit is a password input, everything the user types should be shown as dots, but the LineEdit should still show plain text to the user?!

          Have you tried "myLineedit->setText(TEXT);"
          Idk if it's working out of the box, otherwise switch echo mode off, show text and turn it on again.

          A Offline
          A Offline
          Alam
          wrote on last edited by
          #4

          @Pl45m4 thanks for quick response. Pardon me for putting the question wrong. What I want is when in NO ECHO mode i should be able to edit any text or write any text to LineEdit using setText(). but in NO ECHO mode i'm not able to set text using setText() and displayText().

          Pl45m4P 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Alam said in How to edit text in line edit when echo mode is ON.:

            what i mean is line edit should not take inputs from the user but should display text when i write to it

            This is not clear to me: what do you mean by "when i write to it"? Do you mean user edits it or do you mean you want to set the text in code? First one does not make sense, the second one is easy (see what @Pl45m4 wrote).

            A Offline
            A Offline
            Alam
            wrote on last edited by
            #5

            @jsulm Pardon me for putting the question wrong. What I wanted to convey is, I want to disable the editing functionality to user but I want the LineEdit to be used by me for displaying some text in the code. Using NO ECHO mode the user cannot edit anything in the LineEdit, this is one part of the question which serves my purpose. The other question is "is it possible to write any text into the LineEdit using setText() or displayText() in the code when in NO ECHO mode". basically I want the LineEdit to be used as just a display to the user in which I should be able to change the text and user should not have that privilege.

            Pl45m4P 1 Reply Last reply
            0
            • A Alam

              @Pl45m4 thanks for quick response. Pardon me for putting the question wrong. What I want is when in NO ECHO mode i should be able to edit any text or write any text to LineEdit using setText(). but in NO ECHO mode i'm not able to set text using setText() and displayText().

              Pl45m4P Offline
              Pl45m4P Offline
              Pl45m4
              wrote on last edited by
              #6

              @Alam said in How to edit text in line edit when echo mode is ON.:

              What I want is when in NO ECHO mode i should be able to edit any text or write any text to LineEdit using setText(). but in NO ECHO mode i'm not able to set text using setText() and displayText().

              This makes no sense to me (Typo ON != NO ECHO MODE?)

              myLineEdit->setText("TEXT");
              

              Forces the LineEdit to show the TEXT, if nothing happend, then there is something wrong with your LineEdit initialization


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              1 Reply Last reply
              0
              • A Alam

                @jsulm Pardon me for putting the question wrong. What I wanted to convey is, I want to disable the editing functionality to user but I want the LineEdit to be used by me for displaying some text in the code. Using NO ECHO mode the user cannot edit anything in the LineEdit, this is one part of the question which serves my purpose. The other question is "is it possible to write any text into the LineEdit using setText() or displayText() in the code when in NO ECHO mode". basically I want the LineEdit to be used as just a display to the user in which I should be able to change the text and user should not have that privilege.

                Pl45m4P Offline
                Pl45m4P Offline
                Pl45m4
                wrote on last edited by Pl45m4
                #7

                @Alam said in How to edit text in line edit when echo mode is ON.:

                basically I want the LineEdit to be used as just a display to the user in which I should be able to change the text and user should not have that privilege

                You could use a QLabel for that purpose too. Labels are not editable, but you can show text anytime.

                And if you dont need a password input field, you can just set your QLineEdit to ReadOnly.

                myLineEdit->setReadOnly(true);
                

                This prevents the user from typing stuff in and you still can display text.

                Setting text to a label / textfield cant be that hard.....

                EDIT:

                What I want is when in NO ECHO mode i should be able to edit any text or write any text to LineEdit using setText()

                NO ECHO suppresses ANY text... so... yes, you can not display text in this mode. The text is actually there, but nothing will be displayed (-> Echo mode, in most cases, is for password inputs. NoEcho hides the password lenght, because it doesnt show anything)


                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                A 1 Reply Last reply
                2
                • Pl45m4P Pl45m4

                  @Alam said in How to edit text in line edit when echo mode is ON.:

                  basically I want the LineEdit to be used as just a display to the user in which I should be able to change the text and user should not have that privilege

                  You could use a QLabel for that purpose too. Labels are not editable, but you can show text anytime.

                  And if you dont need a password input field, you can just set your QLineEdit to ReadOnly.

                  myLineEdit->setReadOnly(true);
                  

                  This prevents the user from typing stuff in and you still can display text.

                  Setting text to a label / textfield cant be that hard.....

                  EDIT:

                  What I want is when in NO ECHO mode i should be able to edit any text or write any text to LineEdit using setText()

                  NO ECHO suppresses ANY text... so... yes, you can not display text in this mode. The text is actually there, but nothing will be displayed (-> Echo mode, in most cases, is for password inputs. NoEcho hides the password lenght, because it doesnt show anything)

                  A Offline
                  A Offline
                  Alam
                  wrote on last edited by
                  #8

                  @Pl45m4 Thank you for the solution and let me know how to make this question as solved.

                  Pl45m4P 1 Reply Last reply
                  0
                  • A Alam

                    @Pl45m4 Thank you for the solution and let me know how to make this question as solved.

                    Pl45m4P Offline
                    Pl45m4P Offline
                    Pl45m4
                    wrote on last edited by Pl45m4
                    #9

                    @Alam

                    There is a menu below (bottom right) your first post. If you click it, there is an option "Mark as solved"


                    If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                    ~E. W. Dijkstra

                    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