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. Best approach to setting cells in table widget
Forum Updated to NodeBB v4.3 + New Features

Best approach to setting cells in table widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 228 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #1

    Given a table widget (pointed to by imageList) whose data is held as QStrings, if I want to update specific columns for a row which I can identify by its content, is this the best approach:

    	for (int row = 0; row < imageList->rowCount(); ++row)
    	{
    		if (name == imageList->item(row, static_cast<int>(ImageListColumns::File))->text())
    		{
    			imageList->item(row, static_cast<int>(ImageListColumns::dX))->setText(QLocale::toString(dX, 'f', 2));
    			imageList->item(row, static_cast<int>(ImageListColumns::dY))->setText(QLocale::toString(dX, 'f', 2));
    			imageList->item(row, static_cast<int>(ImageListColumns::Angle))->setText(QLocale::toString(angle, 'f', 2));
    			break;
    		}
    	}
    

    If not how should I handle this?

    Thanks
    David

    JonBJ 1 Reply Last reply
    0
    • PerdrixP Perdrix

      Given a table widget (pointed to by imageList) whose data is held as QStrings, if I want to update specific columns for a row which I can identify by its content, is this the best approach:

      	for (int row = 0; row < imageList->rowCount(); ++row)
      	{
      		if (name == imageList->item(row, static_cast<int>(ImageListColumns::File))->text())
      		{
      			imageList->item(row, static_cast<int>(ImageListColumns::dX))->setText(QLocale::toString(dX, 'f', 2));
      			imageList->item(row, static_cast<int>(ImageListColumns::dY))->setText(QLocale::toString(dX, 'f', 2));
      			imageList->item(row, static_cast<int>(ImageListColumns::Angle))->setText(QLocale::toString(angle, 'f', 2));
      			break;
      		}
      	}
      

      If not how should I handle this?

      Thanks
      David

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

      @Perdrix
      Code is fine. Not sure what your question is. If you identify the row by comparing the text of one column against what you are looking for that's OK. Then you set each column's item to some text that's OK.

      If, for example, there were other magical calls, such as "set a whole row of columns to this list of values" then it would be documented, but it isn't.

      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