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. Do QLabels and QTextEdits get updated automatically ?
Qt 6.11 is out! See what's new in the release blog

Do QLabels and QTextEdits get updated automatically ?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.5k Views 1 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.
  • M Offline
    M Offline
    mulligan252
    wrote on last edited by
    #1

    Hi,

    I am creating a GUI which I want displaying parameters from a camera (Using QTango). If the camera parameters change, I expect to automatically see the changes on my GUI in the QLabels straight away without interaction.

    I have my mainwindow.h , mainwindow.cpp, ui_mainwindow.h and main.cpp files.

    I am confused as to where to put the code for this.

    Do I create an object of Mainwindow in main.cpp and assign the values to the QLabel of that object there? In that case, doesn't main just get executed once and therefore only put the values once and not updating when they change? Or should the code go elsewhere?

    I'm new to Qt and unsure how it works. Thanks

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

      Hi,

      You should first start with the Qt widget tutorial, you'll have a better grasp on how it works.

      @
      int main(int argc, char *argv[])
      {
      QApplication app(argc, argv);
      MyMainWindow mw;
      mw.show();
      return app.exec(); <- here is the magic, the event loop starts and you'll have your GUI running until you quit it
      }
      @

      Basically you create a subclass of the appropriate widget (QWidget, QDialog, QMainWindow) and modify it to your needs.

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

        Is this the only code that goes in the main function?

        For example, If I want to assign a variable to a QLabel on my GUI. Do I do it in the main function such as mw.myLabel->setText("") etc. ? Thanks

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Look into the concept of signals and slots (and note that a function like setText is a slot).

          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