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 make a widget that could input the text then the text became the widget
Forum Updated to NodeBB v4.3 + New Features

how to make a widget that could input the text then the text became the widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 5 Posters 391 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.
  • nicker playerN Offline
    nicker playerN Offline
    nicker player
    wrote on last edited by
    #1

    I just added the qedittext into my project.and i want to wrote a widget that the qedittext could input the text.and when the text was finished ,then the text part just inputed became the other widget(such as the qpushbutton else).so how to figure it out?it is too hard for me to get the whole part.

    Pl45m4P 1 Reply Last reply
    0
    • JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      If you want to show one widget in the place of the other you can use QStackedWidget. So after the user has entered text into say, a QLineEdit take the text, set it to a QPushButton or Qlabel's text, and switch to that in the QStackedWidget instead of the QLineEdit.

      If you don't care about hiding the original QLineEdit then you don't need a QStackedWidget.

      To create a new widget use new. You can place it wherever on an existing layout.

      All you really need is pushButton->setText(lineEdit->text()), so what is hard?

      nicker playerN 1 Reply Last reply
      1
      • nicker playerN nicker player

        I just added the qedittext into my project.and i want to wrote a widget that the qedittext could input the text.and when the text was finished ,then the text part just inputed became the other widget(such as the qpushbutton else).so how to figure it out?it is too hard for me to get the whole part.

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

        @nicker-player

        So basically QItemDelegate behavior?!
        When you click the widget you get lineEdit editor to write text and when you are done wirh writing, you switch to "display" mode and just show the text?!


        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
        1
        • JonBJ JonB

          If you want to show one widget in the place of the other you can use QStackedWidget. So after the user has entered text into say, a QLineEdit take the text, set it to a QPushButton or Qlabel's text, and switch to that in the QStackedWidget instead of the QLineEdit.

          If you don't care about hiding the original QLineEdit then you don't need a QStackedWidget.

          To create a new widget use new. You can place it wherever on an existing layout.

          All you really need is pushButton->setText(lineEdit->text()), so what is hard?

          nicker playerN Offline
          nicker playerN Offline
          nicker player
          wrote on last edited by
          #4

          @JonB 8959b16b-58a0-4794-88c3-d9aa981bfbdf-image.png
          what I just mentioned looks like the pic above.when inputed the "w" part then the text became the qlabel or qpushbutton something.

          jsulmJ 1 Reply Last reply
          0
          • nicker playerN nicker player

            @JonB 8959b16b-58a0-4794-88c3-d9aa981bfbdf-image.png
            what I just mentioned looks like the pic above.when inputed the "w" part then the text became the qlabel or qpushbutton something.

            jsulmJ Online
            jsulmJ Online
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @nicker-player This picture does not help to understand what you want to do. But my understanding is same as @JonB : you can use QStackedWidget...

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

            1 Reply Last reply
            1
            • jeremy_kJ Offline
              jeremy_kJ Offline
              jeremy_k
              wrote on last edited by
              #6

              I interpreted the OP description as something along the lines of GitLab's search input, where free text that is recognized as a keyword is replaced with a label:

              image.png

              Asking a question about code? http://eel.is/iso-c++/testcase/

              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