Results 1 to 7 of 7

Thread: Problem with QModelIndex

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2008
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Problem with QModelIndex

    Hi everybody, I'm writing a program with QT 4.4
    I'm writing a program to read email from a SQLite database, I used a QSqlQueryModel and a QTableView, when I select a row of the table it returns a QModelIndex
    Qt Code:
    1. connect(myTable, SIGNAL(clicked(QModelIndex)),myTextBrowser, SLOT(dispayMail(QModelIndex)));
    To copy to clipboard, switch view to plain text mode 
    I want that instead a QModelIndex it returns the email id, or else, how i get the email id from the QModelIndex?

    Here is the code: (just a part of it, if you need more I will post it)

    Qt Code:
    1. QSqlQuery query("SELECT email.id,addresses.name,email.subject,email.date FROM email,addresses WHERE addresses.id=email.'from'");
    2. model = new QSqlQueryModel;
    3. model->setQuery(query);
    4. model->removeColumn(0); // don't show the ID
    5. model->setHeaderData(0, Qt::Horizontal, tr("Da"));
    6. model->setHeaderData(1, Qt::Horizontal, tr("Soggetto"));
    7. model->setHeaderData(2, Qt::Horizontal, tr("Data"));
    8.  
    9. this->setShowGrid(FALSE);
    10. this->verticalHeader()->hide();
    11. this->setEditTriggers(QAbstractItemView::NoEditTriggers);
    12. this->setSelectionMode(QAbstractItemView::ContiguousSelection);
    13. this->setSelectionBehavior(QAbstractItemView::SelectRows);
    14. this->setSelectionMode(QAbstractItemView::ExtendedSelection);
    15. this->setModel(model);
    16. this->show();
    To copy to clipboard, switch view to plain text mode 

    Thanks

    Ps: Sorry for my english, but I'm swiss
    Last edited by wysota; 30th October 2008 at 07:54. Reason: Changed [qtclass] to [code]

Similar Threads

  1. QSql*Model + QTreeView : make a tree
    By punkypogo in forum Qt Programming
    Replies: 18
    Last Post: 24th October 2008, 18:14
  2. QModelIndex problem!
    By landonmkelsey in forum Qt Programming
    Replies: 10
    Last Post: 28th August 2008, 19:46
  3. Problem with TreeView
    By init2null in forum Qt Programming
    Replies: 8
    Last Post: 25th May 2008, 09:56
  4. QAbstractItemModel newbie question
    By okellogg in forum Qt Programming
    Replies: 14
    Last Post: 18th February 2008, 12:30
  5. Replies: 6
    Last Post: 21st September 2007, 13:51

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.