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. It is posible to update text in a mainwindow lineedit?

It is posible to update text in a mainwindow lineedit?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 1.6k 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.
  • D Offline
    D Offline
    davelnx
    wrote on last edited by
    #1

    I am receiving Information from a source it is possible to show that information in a lineedit or example as I get it. The lined is in a mainwindow. What approach should I take? Thank you

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Yes it is. What source are you talking about ?

      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
      • D Offline
        D Offline
        davelnx
        wrote on last edited by
        #3

        Hello,
        I am able to get the text from the text() function of the LineEdit but it does not show in the UI.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Can you share your code ?

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

          D 1 Reply Last reply
          0
          • D Offline
            D Offline
            davelnx
            wrote on last edited by
            #5

            #include "mylistener.h"
            #include "mainwindow.h"
            #include <QDebug>

            MyListener ::MyListener()
            {

            mai= new MainWindow();
            

            }

            void MyListener::onFrame(const Controller& controller){
            const Frame frame = controller.frame();
            handC= frame.hands().count();
            int id =frame.id();
            QString sid = QString::number(id);
            qDebug() << sid <<endl;

            hndc= QString::number(handC);
            qDebug() << hndc <<endl;
            mai->updatehand(hndc);

            }

            MaininWindow::MainWindow()
            {
            handsRead = new QLineEdit();
            connect(this, SIGNAL(hChanged(QString)),
            this, SLOT(setH(QString)));
            }
            void MainWindow::setH( QString hndc){
            handsRead->setText(hndc);
            }

            void MainWindow::updatehand(QString sthc){
            emit hChanged(sthc);
            }

            1 Reply Last reply
            0
            • SGaistS SGaist

              Can you share your code ?

              D Offline
              D Offline
              davelnx
              wrote on last edited by
              #6

              @SGaist The MyListener class get the frames from LeapMotion sensor, then every time I get a frame I send the number of hands converted to String to the MainWindow's function updatehand. Is there something wrong in my code that don't let me update the UI QLineEdit. Thank you.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                davelnx
                wrote on last edited by
                #7

                I was able to fix it. Thank you

                #include "mylistener.h"
                #include "mainwindow.h"
                #include <QDebug>

                MyListener ::MyListener()
                {
                myhand_C=0;
                le = new QLineEdit();
                mai.setCentralWidget(le);
                mai.show();
                }

                void MyListener::onFrame(const Controller& controller){
                const Frame frame = controller.frame();
                handC= frame.hands().count();
                int id =frame.id();
                QString sid = QString::number(id);
                qDebug() << sid <<endl;
                hndc= QString::number(handC);
                qDebug() << hndc <<endl;
                myhand_C= handC;
                //emit mai->hChanged(hndc);
                //mai->updatehand(hndc);
                le->setText(hndc);
                //qDebug()<<mai->handsRead->text()<<endl;

                }

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  If I may, your MyListener class does too much things. It should only be responsible of listening to the device and handle frames coming from it. The GUI part should not be it's job at all.

                  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

                  • Login

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