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. QTableWidget how to get number of rows in each cell
Forum Updated to NodeBB v4.3 + New Features

QTableWidget how to get number of rows in each cell

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 969 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.
  • D Offline
    D Offline
    dzungng
    wrote on 31 Mar 2021, 13:43 last edited by dzungng
    #1

    Hi,

    i created a table with a given number of rows and columns. I also used setSpan() to merge some cells together.

    Now i need to retrieve the number of rows and columns in each cell after merging. Is there a method to loop through all merged cells to get the data I want?

    I thought of using rowCount() and columnCount() but it only works with the whole table.

    Thank you all

    J 1 Reply Last reply 31 Mar 2021, 14:20
    0
    • D dzungng
      31 Mar 2021, 13:43

      Hi,

      i created a table with a given number of rows and columns. I also used setSpan() to merge some cells together.

      Now i need to retrieve the number of rows and columns in each cell after merging. Is there a method to loop through all merged cells to get the data I want?

      I thought of using rowCount() and columnCount() but it only works with the whole table.

      Thank you all

      J Online
      J Online
      JonB
      wrote on 31 Mar 2021, 14:20 last edited by
      #2

      @dzungng
      You have to march through the cells of the table reading their QTableView::column/rowSpan(int row, int column) to calculate what is there including spanning.

      1 Reply Last reply
      3
      • D Offline
        D Offline
        dzungng
        wrote on 31 Mar 2021, 14:29 last edited by
        #3

        Thank you for your answer.
        I created a table using QTableWidget. Can I use the function you recommended for QTableWidget?

        J 1 Reply Last reply 31 Mar 2021, 15:05
        0
        • D dzungng
          31 Mar 2021, 14:29

          Thank you for your answer.
          I created a table using QTableWidget. Can I use the function you recommended for QTableWidget?

          J Online
          J Online
          JonB
          wrote on 31 Mar 2021, 15:05 last edited by JonB
          #4

          @dzungng
          QTableWidget inherits from QTableView. That means all QTableView methods are also available on a QTableWidget. This principle is worth understanding, as it applies all over the place with QWidgets (and other Qt derived classes).

          1 Reply Last reply
          4

          1/4

          31 Mar 2021, 13:43

          • 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