Results 1 to 4 of 4

Thread: How to access QListView QChecklistItem fields?

  1. #1
    Join Date
    Aug 2007
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    3

    Default How to access QListView QChecklistItem fields?

    Hello

    The code below is taken from an example and works fine.
    I will use it during the startup for presenting the self test flow and results(any better way?).
    The problem is:
    Currently the first column is accessable ,but I dont know how to enter the test results to the second column.I want to enter some text as test results like passed ,running or/and related icons .

    Yekta Ayduk


    Qt Code:
    1. CheckLists::CheckLists( QWidget *parent, const char *name )
    2. : QWidget( parent, name )
    3. {
    4.  
    5. QHBoxLayout *lay = new QHBoxLayout( this );
    6. lay->setMargin( 5 );
    7.  
    8. // create a widget which layouts its childs in a column
    9. QVBoxLayout *vbox1 = new QVBoxLayout( lay );
    10. vbox1->setMargin( 5 );
    11.  
    12. // First child: a Label
    13. vbox1->addWidget( new QLabel( "Check some items!", this ) );
    14.  
    15. // Second child: the ListView
    16. lv1 = new QListView( this );
    17. vbox1->addWidget( lv1 );
    18.  
    19. lv1->addColumn( "Test Items" );
    20. lv1->addColumn( "Test Results" );
    21.  
    22. lv1->setRootIsDecorated( TRUE );
    23.  
    24.  
    25. QValueList<QListViewItem *> parentList;
    26.  
    27. parentList.append( new QCheckListItem( lv1, "Test Items", QCheckListItem::CheckBoxController ) );
    28.  
    29. QListViewItem *item = 0;
    30.  
    31. QValueList<QListViewItem*>::Iterator it = parentList.begin();
    32. ( *it )->setOpen( TRUE );
    33. item = *it;
    34.  
    35. test_1= new QCheckListItem( item, "Test 1", QCheckListItem::CheckBox );
    36. test_2= new QCheckListItem( item, "Test 2", QCheckListItem::CheckBox );
    37. test_3= new QCheckListItem( item, "Test 3", QCheckListItem::CheckBox );
    38.  
    39. test_3->setOn(TRUE);//executed test selected by code
    40.  
    41. //mouse keyboard selection disabled
    42. test_1->setSelectable(FALSE);
    43. test_2->setSelectable(FALSE);
    44. test_3->setSelectable(FALSE);
    45.  
    46. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 9th January 2008 at 21:52. Reason: missing [code] tags

  2. #2
    Join Date
    Aug 2007
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    3

    Default Re: How to access QListView QChecklistItem fields?

    By adding these lines ,I can place text into test_result column .But it is placed at the next row after test_3 row ,still dont know how to place to any (column,row) at anytime?

    Qt Code:
    1. //----------------------Filling Column 2-----------------------------
    2.  
    3. QString qstr_passed=QString("passed");
    4. test_1_result=new QListViewItem( lv1 );
    5. test_1_result->setText ( 1, qstr_passed );
    6.  
    7. //----------------------end Filling Column 2-----------------------------
    To copy to clipboard, switch view to plain text mode 

    yekta ayduk
    Last edited by jpn; 9th January 2008 at 21:52. Reason: missing [code] tags

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

    Default Re: How to access QListView QChecklistItem fields?

    Just invoke setText() on one of the items you have created earlier.

    Qt Code:
    1. test_1->setText( 1, "aaa" );
    To copy to clipboard, switch view to plain text mode 

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

    yektaayduk (9th January 2008)

  5. #4
    Join Date
    Aug 2007
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    3

    Default Re: How to access QListView QChecklistItem fields?

    Ok,it works.
    I was mistaken in supposing that the columns are not related .

    Thanks jacek.

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.