Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to design the code for dynamic created the tablewidgetitems?
Qt 6.12 LTS is out! See what's new in the release blog

How to design the code for dynamic created the tablewidgetitems?

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

    The project has a feature to acomplish that created the tablewidgettiems dynamically.
    I use the code like this

    when init the tablewidgettiems by using the code like this

    for(int size_count;size_count<size_target;size_count++)
          TableWidgetItems.create() ... code
    

    when update the tablewidgettiems like this

    update size_count;
    delelte TableWidgetItems;
    for(int size_count;size_count<size_target;size_count++)
          TableWidgetItems.create() ... code
    

    and the code seemed so ugly and unusefully ,so anyone could show me an useful way to design the code?

    jsulmJ 1 Reply Last reply
    0
    • nicker playerN nicker player

      The project has a feature to acomplish that created the tablewidgettiems dynamically.
      I use the code like this

      when init the tablewidgettiems by using the code like this

      for(int size_count;size_count<size_target;size_count++)
            TableWidgetItems.create() ... code
      

      when update the tablewidgettiems like this

      update size_count;
      delelte TableWidgetItems;
      for(int size_count;size_count<size_target;size_count++)
            TableWidgetItems.create() ... code
      

      and the code seemed so ugly and unusefully ,so anyone could show me an useful way to design the code?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @nicker-player Sorry, I don't understand the problem.
      And you only posted some pseudo-code, so how can anybody know what you mean by "ugly and unusefully"?
      Please post your real code and explain what you do not like about it.

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

      1 Reply Last reply
      1
      • nicker playerN Offline
        nicker playerN Offline
        nicker player
        wrote on last edited by
        #3

        In fact,there are lots of files of the codes,and is hard to publish on the forum.
        And I just want to learn some codes about dynamically created the tablewidgetitems based on the input content by the users.
        It would be good if there's an example of what I just want to figured out.

        JonBJ jsulmJ 2 Replies Last reply
        0
        • nicker playerN nicker player

          In fact,there are lots of files of the codes,and is hard to publish on the forum.
          And I just want to learn some codes about dynamically created the tablewidgetitems based on the input content by the users.
          It would be good if there's an example of what I just want to figured out.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @nicker-player said in How to design the code for dynamic created the tablewidgetitems?:

          In fact,there are lots of files of the codes,and is hard to publish on the forum.

          Then reduce it to some minimal example of what you want --- nobody wants to look through masses of irrelevant code.

          It would be good if there's an example of what I just want to figured out.

          I'm afraid nobody knows what you have in mind, so nobody will know what example you are looking for.

          1 Reply Last reply
          0
          • nicker playerN nicker player

            In fact,there are lots of files of the codes,and is hard to publish on the forum.
            And I just want to learn some codes about dynamically created the tablewidgetitems based on the input content by the users.
            It would be good if there's an example of what I just want to figured out.

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

            @nicker-player said in How to design the code for dynamic created the tablewidgetitems?:

            In fact,there are lots of files of the codes,and is hard to publish on the forum.

            I did not ask you to post all the code you have. I asked you to post RELEVANT code which you do not like. Why is it so hard? How should anybody understand what you are asking from what you posted so far?

            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
            • Unsolved