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. how to load enter data in qtable view?
Forum Updated to NodeBB v4.3 + New Features

how to load enter data in qtable view?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 290 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.
  • N Offline
    N Offline
    Nayan Thapa Magar
    wrote on last edited by
    #1
    This post is deleted!
    JonBJ 1 Reply Last reply
    0
    • MarKSM Offline
      MarKSM Offline
      MarKS
      wrote on last edited by MarKS
      #2

      First thing you need is a model to add data and then you can use QTableView to show your data. You can use QStandardItemModel for now, as it is easier to handle data as a beginner.

      Follow this to understand how the model works with a view.

      To insert rows may be this will help you.

      1 Reply Last reply
      0
      • N Nayan Thapa Magar

        This post is deleted!

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

        @Nayan-Thapa-Magar

        1. Write your model, with columns quantity, rate, total, product name. You might use a custom model, a QStandardItemModel or a QSqlTableModel if you are using an actual database. Store the numeric columns to hold numbers, not strings.

        2. Add a QTableView for the model. Alternatively, you could make it a QTableWidget, in which the case model mentioned in #1 will already be attached to it (QTableWidget has its own inbuilt model).

        3. Get that working to display whatever rows the table has.

        4. Easiest is if you add something like QPushButton just below (not inside) the table. Clicking it adds a new, blank row at the end of the table, for a new item. Or have dedicated widgets for the user to pick what he wants and a button to add that as the row. There are other ways too.

        5. (Probably) extend the QTableWidget/QTableView to allow columns Modify and Remove with their own buttons against each row.

        For adding/modifying you have a choice: you can have dedicated widgets outside the table where you copy rows/do your editing, or you can make your QTableWidget/QTableView allow editing in selected row, changing values inside the actual row.

        That's the outline.

        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