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. Show value entered in QTextEdit by user in a QLabel when user click submit button
Forum Updated to NodeBB v4.3 + New Features

Show value entered in QTextEdit by user in a QLabel when user click submit button

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.2k 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.
  • S Offline
    S Offline
    sanjay1155
    wrote on last edited by A Former User
    #1

    How can I show the value entered in QTextEdit by user in a QLabel when user click a submit button?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      QObject::connect(submitButton,&QPushButton::clicked,[=]()->void{label->setText(textEdit->toPlainText());});

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      1
      • M Offline
        M Offline
        mostefa
        wrote on last edited by A Former User
        #3

        @sanjay1155

        Hi it's very simple ,

        If you are using Qt widgets you you can do something like this:

        connect(ui->submitButton,SIGNAL(clicked()),this,SLOT(onTextValidated()));
        
        private slot:
        void onTextValidated();
        

        in .cpp

        onTextValidated()
        {
            ui->label->setText(ui->textEdit->toPlainText());
        }
        

        Hope this can help!

        Edit: Added code tags -- @Wieland

        1 Reply Last reply
        1
        • S Offline
          S Offline
          sanjay1155
          wrote on last edited by
          #4

          @VRonin
          where do i need t put this code in Mainwindow::Mainwindow() function or in the slot when my button is clicked ?

          VRoninV 1 Reply Last reply
          0
          • S sanjay1155

            @VRonin
            where do i need t put this code in Mainwindow::Mainwindow() function or in the slot when my button is clicked ?

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by VRonin
            #5

            @sanjay1155 said in Show value entered in textedit by user in a label when user click submit button:

            in Mainwindow::Mainwindow() function

            yes, in the constructor

            slot when my button is clicked

            if you already have a slot connected to QPushButton::clicked just add label->setText(textEdit->toPlainText()); to it instead of using my code

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            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