Results 1 to 7 of 7

Thread: Documentation problem.

  1. #1
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Documentation problem.

    I am fairly new to Qt and I am having problem in decoding some of the documentation, particularly in Qt4.
    Example:. I have a QTableWidget, "myTable", and I want to myTable->set Item(3, 4, "somthing");
    What should the code look like?

    The Doc. has "void QTableWidget::setItem ( int row, int column, QTableWidgetItem * item )". Fine, but....

    I go to QTableWidgetItem and am totally lost.

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Documentation problem.

    Quote Originally Posted by impeteperry View Post
    I have a QTableWidget, "myTable", and I want to myTable->set Item(3, 4, "somthing");
    What should the code look like?
    It should be:
    Qt Code:
    1. myTable->setItem( 3, 4, new QTableWidgetItem( "somthing" ) );
    To copy to clipboard, switch view to plain text mode 

    QTableWidgetItem represents the cell in the table.

  3. The following user says thank you to jacek for this useful post:

    tpf80 (18th June 2007)

  4. #3
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Documentation problem.

    Thanks for the prompt, helpful reply. I found about the samething in chapt03 of "programming in Qt4".

    I haven't gotten the logic behind the "new" yet since I have designated the "cell", but I shall. Thanks.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Documentation problem.

    Quote Originally Posted by impeteperry View Post
    I haven't gotten the logic behind the "new" yet since I have designated the "cell", but I shall.
    new is an operator that creates class instance on the heap and returns a pointer to it.

    Qt Code:
    1. myTable->setItem( 3, 4, new QTableWidgetItem( "somthing" ) );
    To copy to clipboard, switch view to plain text mode 
    is equivalent of:
    Qt Code:
    1. QTableWidgetItem *item = new QTableWidgetItem( "somthing" );
    2. myTable->setItem( 3, 4, item );
    To copy to clipboard, switch view to plain text mode 

    It the item already exists, you can access it like this:
    Qt Code:
    1. myWidget->item( 3, 4 )->setText( "something" );
    To copy to clipboard, switch view to plain text mode 

  6. #5
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Documentation problem.

    Ok I think I understand. Each cell is, in effect, a child of the table rather than a part of the table itself and thus must be dclared separately. Am I right?

    Thanks.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Documentation problem.

    Quote Originally Posted by impeteperry View Post
    Each cell is, in effect, a child of the table rather than a part of the table itself and thus must be dclared separately. Am I right?
    Yes, each cell is represented by a distinct object and QTableWidget acts like a container for them.

  8. #7
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Documentation problem.

    Thanks.

    Good Night.

Similar Threads

  1. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.