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. Can we create labels based on data automatically
Forum Updated to NodeBB v4.3 + New Features

Can we create labels based on data automatically

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 262 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.
  • R Offline
    R Offline
    rahuman
    wrote on 29 Feb 2020, 13:32 last edited by
    #1

    Hi ,
    I am recieving udp packets and displaying in qt,Now i am trying to display data in labels, like based on packets automatically labels should create and data should display on labels .Is it possible to do like that any help.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 29 Feb 2020, 14:39 last edited by
      #2

      You really don't want to create a label per udp packet. Take a look at the itemviews.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      4
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 29 Feb 2020, 19:36 last edited by
        #3

        Hi
        Yes you can create QLables dynamically but it gets heavy fast so as Christian-Ehrlicher says,
        a model and a ListView is much more fun.
        You could try out with a QStringListModel if you dont plan to show millions of rows.

        You can see here how to use one.
        https://www.bogotobogo.com/Qt/Qt5_QListView_QStringListModel_ModelView_MVC.php

        it shows how to add new and remove from the model.

        Basically you can place a QListView on the UI form and do

         // Create model
            model = new QStringListModel(this); // its a member
         // Make data
            QStringList List;
            List << "Clair de Lune" << "Reverie" << "Prelude";
         // Populate our model
            model->setStringList(List);
         // Glue model and view together
            ui->listView->setModel(model);
        

        and it will show your list.

        R 1 Reply Last reply 2 Mar 2020, 04:25
        6
        • M mrjj
          29 Feb 2020, 19:36

          Hi
          Yes you can create QLables dynamically but it gets heavy fast so as Christian-Ehrlicher says,
          a model and a ListView is much more fun.
          You could try out with a QStringListModel if you dont plan to show millions of rows.

          You can see here how to use one.
          https://www.bogotobogo.com/Qt/Qt5_QListView_QStringListModel_ModelView_MVC.php

          it shows how to add new and remove from the model.

          Basically you can place a QListView on the UI form and do

           // Create model
              model = new QStringListModel(this); // its a member
           // Make data
              QStringList List;
              List << "Clair de Lune" << "Reverie" << "Prelude";
           // Populate our model
              model->setStringList(List);
           // Glue model and view together
              ui->listView->setModel(model);
          

          and it will show your list.

          R Offline
          R Offline
          rahuman
          wrote on 2 Mar 2020, 04:25 last edited by
          #4

          @mrjj @Christian-Ehrlicher Thanks for reply

          1 Reply Last reply
          0

          1/4

          29 Feb 2020, 13:32

          • Login

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