Results 1 to 6 of 6

Thread: How to save Qstring from QTableView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Re: How to save Qstring from QTableView

    Thank you very much for response, but i have still this error. When I run this function I see in qt error like this:
    ASSERT: "!isEmpty()" in file c:\QtSDK\Desktop\Qt\4.7.3\mingw\include/QtCore/qlist.h, line 273
    Invalid parameter passed to C runtime function.
    Invalid parameter passed to C runtime function.
    When i read your response I modify my code and i have this:
    Qt Code:
    1. QString copy;
    2. QItemSelectionModel *selectionM = ui->tableView->selectionModel();
    3. QModelIndexList selectionL = selectionM->selectedIndexes();
    4. selectionL.removeFirst();
    5. foreach ( const QModelIndex& index, selectionL)
    6. {
    7. list = index.data().toStringList() ;
    8. }
    9. copy =list.join(", ");
    10. QMessageBox::information(this, "Kopiowanie", copy);
    To copy to clipboard, switch view to plain text mode 
    This error results from "selectionL.removeFirst();" but when i removed this line i don't have a char in QString. Sorry for my language but I live in Poland.

  2. #2
    Join Date
    Sep 2010
    Posts
    22
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: How to save Qstring from QTableView

    selectedIndexes() gives you only selection and it seems you haven't selected anything. Threrfore selectionL contains nothing and you have to check whether selectionL empty or not before removeFirst() call.
    Overwriting list inside loop is also obviously not what you want. You probably want to append data to the list, so list.append() should be the way.

  3. #3

    Default Re: How to save Qstring from QTableView

    Ok I check this and selectionL is empty but i don't know why and what should I do. Sorry but I am inexperianced. I create table in this function:
    Qt Code:
    1. model = new QSqlTableModel(this);
    2. model ->setTable(ntabeli);
    3. model ->select();
    4. ui->tableView->setModel(model);
    To copy to clipboard, switch view to plain text mode 
    Last edited by wodzu-96; 24th October 2011 at 20:55.

Similar Threads

  1. Replies: 2
    Last Post: 11th August 2011, 15:42
  2. Replies: 8
    Last Post: 25th November 2010, 11:40
  3. Replies: 3
    Last Post: 1st April 2010, 23:56
  4. Replies: 4
    Last Post: 1st February 2010, 14:21
  5. Replies: 4
    Last Post: 31st January 2008, 20:44

Tags for this Thread

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.