sorry i missed something to say in the above thread, select a data from 1st table and add it to 2nd table it will appear in the 2nd table but when add another data from the first table then in the 2nd table replace the first data with 2nd
sorry i missed something to say in the above thread, select a data from 1st table and add it to 2nd table it will appear in the 2nd table but when add another data from the first table then in the 2nd table replace the first data with 2nd
Beside that you have a memory leak in your function, you replace the model and do not append the new list. So reuse the old model and append the data by getting the old string list, append the new one and set the new composed list back to the model.
breakthecode (4th December 2011)
i want two table views , one is for tabling files in a dir, second one is for real time adding of selected files. i think i need some modification in here
QStringListModel *model2 = new QStringListModel();
QStringList list;
list << selectedtext ;
model2->setStringList(list);
thank you
Well I don't know the architecture of your code, but instead of creating the model each time the function is called do something like thatQt Code:
QStringList newData; // or where ever your data is old << newData; model->setStringList(old);To copy to clipboard, switch view to plain text mode
breakthecode (4th December 2011)
finally i got an another idea, load the string to a file then read the list model from there but when i writing the strings to the file again hits the same problem, only first the first string is saved others are overwrite on the first one. i want to write the strings one after the another, is there any way to solve that
imagine if the vale selectedtext string on first click is hdbhdn.avi second click hgsdjsdff.aviQt Code:
void dcsinter::on_pushButton_clicked() { out << selectedtext << '\n' ; }To copy to clipboard, switch view to plain text mode
then file shows like the below
hgsdjsdff.avi
i want to like this
wdbhdn.avi
hgsdjsdff.avi
i want a continues writing on the file
thank you
I doubt if that is the right solution but you must know... Use also QIODevice::Append at QFile::open().
breakthecode (5th December 2011)
you're right it didn't work that i thought, i need a help here do u have any idea that this codecrash the programQt Code:
To copy to clipboard, switch view to plain text mode
i think i struck in this table issue
Qt Code:
void dcsinter::on_pushButton_clicked() { QStringList list; list << selectedtext ; model->setStringList(list); ui->listtableView_2->setModel(model); ui->listtableView_2->setColumnWidth(0,600); }To copy to clipboard, switch view to plain text mode
i have a question, is QTableView build for adding column with data
Last edited by breakthecode; 5th December 2011 at 14:53. Reason: spelling corrections
Have you checked if ui->listtableView_2->model() is returning a null pointer (= the view hasn't any model yet)? You first have to set a model to the view (best in the constructor) and then you can reuse the model in your on_pushButton_clicked function.
breakthecode (5th December 2011)
thanks 1000
this is what i am looking for 2 days this single piece idea
you said it in the first day but i can't understand it, i now know it's a basic in c++ pro. but i can't understand it, sorry for waisting your time
again thanks , now it's working very well.
Last edited by breakthecode; 5th December 2011 at 18:22. Reason: updated contents
You are welcome.
here i publish the full result of the forum discussion, it's useful for anyone encountering the same problem
aim is to copy a data from a qtableview and add that data to another qtableview
first create a constructor
then on click push buttonQt Code:
void dcsinter::listing() { ui->listtableView_2->setModel(model); }To copy to clipboard, switch view to plain text mode
Qt Code:
void dcsinter::on_pushButton_clicked() { list << selectedtext ; model->setStringList(list); }To copy to clipboard, switch view to plain text mode![]()
Hi, one more improvement to avoid the cast: Make the model a private member of your class an access it directly.
breakthecode (6th December 2011)
Bookmarks