PDA

View Full Version : how i can do like this image



advseo32
22nd July 2013, 08:00
Hi, every body

i have a probleme with inserting a row from a table call tableProduct to another table call tableSalle

when the user click entre key in the first table “tableProduct”

i can’t figured out, how this work

this is an image explains what i means

9315


i think we implement insertrow function


bool MyModel::insertRows(int position, int rows, const QModelIndex &parent)
{
beginInsertRows(QModelIndex(), position, position+rows-1);
// i want to get the event when the user click "Keydown"
if (true)
{
// we add row with empty fields to allow user to fill them
}


endInsertRows();
return true;
}

advseo32
24th July 2013, 00:34
no body can help me ??

KillGabio
24th July 2013, 04:25
You need to capture the signal click on the different tables, to move the rows to the table of interest. For example if you want to do it field by field, you can use
QTableWidgetItem *newItem = new QTableWidgetItem ("No Data");
newItem->setData (Qt::DisplayRole, prixVenteU); that for the last field, and so on. After saving the value you insert it on the table you want. Try giving some code next time.

ChrisW67
24th July 2013, 05:26
I am going to assume the top table is a QTableWidget and the lower table is a QTableView that is displaying a separate model of some sort (the picture is not very helpful). When the user triggers the insert you need to:

Call insertRow() on the model underlying the lower table to insert a 'blank' row.
Keep a note of the new row number.
For each column in the top table:

Get the value in the column from the QTableWidgets model's data() function or through a QTableWidgetItem.
Create a QModelIndex in the lower model for the new row and column you want to put the value into.
Call setData() on the lower model to update the cell

advseo32
24th July 2013, 08:20
example for application that uses this kind of thing is “ Inventory management system” like inflow inventory

if the image is not helpful try this video, maybe you understandme , sorry for my english

https://www.youtube.com/watch?v=hkfmZwuc-YY