October 13, 2011

toho71 toho71
Lab Rat
189 posts

[solved]tableview set/get and other questions.

 

Because I’m a newbee i have some difficulties with many things.
Here is a list about Qtableview.

1)
I select and click on a singel row.
Could I get all of the values from the diffrent columns and put in a array or something.

2)
How could i do so if i uses the arrows to run thru the table the selection changes to the new row.
in other words currnt row change.

3) i want to highlight or “Blink “ som of the rows in the table.
Is it possible.

I’d like exampels

Foregive my bad English but i*m trying

5 replies

October 13, 2011

syrianzoro syrianzoro
Lab Rat
63 posts

1)
I select and click on a singel row.
Could I get all of the values from the diffrent columns and put in a array or something.

Yes, you could , you can catch the suitable signal and get the index of the row then get all the desired results

  1. connect(_myTableView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(doubleClicked(const QModelIndex &)));

2)
How could i do so if i uses the arrows to run thru the table the selection changes to the new row.
in other words currnt row change.

I don’t understand this

3) i want to highlight or “Blink “ som of the rows in the table.
Is it possible.

  1. setAlternatingRowColors(true);

Yes by calling one method

I’d like exampels

Foregive my bad English but i*m trying

 Signature 

Qt is the future

October 13, 2011

toho71 toho71
Lab Rat
189 posts

1)
Yes i do so but in a clickevent on a button and i do like this

  1. QModelIndexList selectedList = ui->testTable->selectionModel()->selectedRows(1);
  2. QModelIndex index = ui->testTable->currentIndex();
  3.  
  4.  for( int i=0; i<selectedList.count(); i++)
  5.   {
  6.         ui->label1->setText(selectedList.at(i).data().toString());
  7.   }

I can only get the columnvalue from ->selectedRows(1);
is there an easier way to do this

_____________________
2) it was ment to catch the currentrow when i change row with my arrow buttons or swipe.
Is it possible.

I want to put the values from the current row in labels.

October 13, 2011

syrianzoro syrianzoro
Lab Rat
63 posts

you have to get the model Index not the view

 Signature 

Qt is the future

October 13, 2011

syrianzoro syrianzoro
Lab Rat
63 posts

  1.  QAbstractItemModel dataModel;
  2.  QTableView myTableView;

reimplement the QAbstractItemModel make the list as data container

 Signature 

Qt is the future

October 13, 2011

toho71 toho71
Lab Rat
189 posts

Thanks but iI’m not sure how to do it.

I try to do this also on row change

  1.  connect(ui->testTable, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
  2.     this, SLOT(selectionChanged(QModelIndex, QModelIndex)));

But nothing happens

 
  ‹‹ Floating child widget      [SOLVED] Problem with duplication of Value in QTabWidget ››

You must log in to post a reply. Not a member yet? Register here!