PDA

View Full Version : How to access QListView QChecklistItem fields?



yektaayduk
9th January 2008, 06:51
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



CheckLists::CheckLists( QWidget *parent, const char *name )
: QWidget( parent, name )
{

QHBoxLayout *lay = new QHBoxLayout( this );
lay->setMargin( 5 );

// create a widget which layouts its childs in a column
QVBoxLayout *vbox1 = new QVBoxLayout( lay );
vbox1->setMargin( 5 );

// First child: a Label
vbox1->addWidget( new QLabel( "Check some items!", this ) );

// Second child: the ListView
lv1 = new QListView( this );
vbox1->addWidget( lv1 );

lv1->addColumn( "Test Items" );
lv1->addColumn( "Test Results" );

lv1->setRootIsDecorated( TRUE );


QValueList<QListViewItem *> parentList;

parentList.append( new QCheckListItem( lv1, "Test Items", QCheckListItem::CheckBoxController ) );

QListViewItem *item = 0;

QValueList<QListViewItem*>::Iterator it = parentList.begin();
( *it )->setOpen( TRUE );
item = *it;

test_1= new QCheckListItem( item, "Test 1", QCheckListItem::CheckBox );
test_2= new QCheckListItem( item, "Test 2", QCheckListItem::CheckBox );
test_3= new QCheckListItem( item, "Test 3", QCheckListItem::CheckBox );

test_3->setOn(TRUE);//executed test selected by code

//mouse keyboard selection disabled
test_1->setSelectable(FALSE);
test_2->setSelectable(FALSE);
test_3->setSelectable(FALSE);

}

yektaayduk
9th January 2008, 08:45
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?:(



//----------------------Filling Column 2-----------------------------

QString qstr_passed=QString("passed");
test_1_result=new QListViewItem( lv1 );
test_1_result->setText ( 1, qstr_passed );

//----------------------end Filling Column 2-----------------------------


yekta ayduk

jacek
9th January 2008, 15:02
Just invoke setText() on one of the items you have created earlier.


test_1->setText( 1, "aaa" );

yektaayduk
9th January 2008, 20:10
Ok,it works.
I was mistaken in supposing that the columns are not related .

Thanks jacek.