Results 1 to 2 of 2

Thread: Retreive QValueVector value

  1. #1
    Join Date
    Jan 2006
    Location
    Third rock from the sun
    Posts
    106
    Thanks
    17
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Retreive QValueVector value

    NOTE: I am retyping this in, since the code is on a standalone machine with no internet access. Please ignore any spelling mistakes!

    I have the following QValueVector declared:
    Qt Code:
    1. struct TableData{
    2. bool shown;
    3. QVariant data;
    4. QColor color;
    5. }
    6.  
    7. QValueVector< QValueVector<TableData> > mDataTable;
    To copy to clipboard, switch view to plain text mode 

    Subclassing QTable using the TableData, sucessfully popluates the table, however I am trying to reimplement the header sorting functions and getting a compile error:

    Qt Code:
    1. QValueVector< QValueVector<TableData> > sortedVector;
    2. sortedVector.push_back( mDataTable[0] ); // Works just fine
    3.  
    4. QValueVector< QValueVector<TableData> >::iterator it;
    5.  
    6. for( int i = 1; i < mDataTable.size( ); i++ )
    7. {
    8. for( it = sortedVector.begin( ); it != sortedVector.end( ); it++ )
    9. {
    10. // Two errors on this line both dealing with accessing data from the vector
    11. if( mDataTable[i][column].data.toString( ) < it[column].data.toString( ) )
    12. :
    13. :
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 

    The Error says:
    Error: data is not a member of QValueVector<TableData>.
    for both .data accesses. Is there something I am not understanding about Qt3 vectors?
    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Talking Re: Retreive QValueVector value

    I believe you need to change your if-statement to look like:

    Qt Code:
    1. if( mDataTable[i][column].data.toString( ) < *( it->at( column ) ).data.toString( ) )
    To copy to clipboard, switch view to plain text mode 

    This should fix both of your compiler errors.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.