Results 1 to 5 of 5

Thread: problem with getting info from tableView

  1. #1
    Join Date
    Apr 2010
    Location
    Sudan
    Posts
    46
    Thanks
    7
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question problem with getting info from tableView

    hi ..
    i want to get cell content from table view (ui->tableView)

    how can i do that ??

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: problem with getting info from tableView

    Quote Originally Posted by tinysoft View Post
    how can i do that ??
    Not by posting twice
    Get the index of the cell (e.g. QAbstractItemView::currentIndex()) and then use the data function to receive the content. (see QModelIndex::data())

  3. #3
    Join Date
    Apr 2010
    Location
    Sudan
    Posts
    46
    Thanks
    7
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem with getting info from tableView

    Quote Originally Posted by Lykurg View Post
    Not by posting twice
    sorry about that .. problem with the browser caused it .

    one more question : how can i use ( QVariant QModelIndex::data ( int role = Qt:isplayRole ) const ) if i want to get item (1,1) for example ??

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: problem with getting info from tableView

    You just have to combine the two functions:
    Qt Code:
    1. QAbstractItemModel *model = ui->tableView->model(); // if you don't have a class wide pointer to your model;
    2. if (!model)
    3. return;
    4. QModelIndex index = model->index(1,1);
    5. if(!index.isValid)
    6. return;
    7. qDebug() << index.data().toString();
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to Lykurg for this useful post:

    tinysoft (19th August 2010)

  6. #5
    Join Date
    Apr 2010
    Location
    Sudan
    Posts
    46
    Thanks
    7
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem with getting info from tableView

    great thanks !

Similar Threads

  1. problem with getting info from tableView
    By tinysoft in forum Newbie
    Replies: 0
    Last Post: 19th August 2010, 12:33
  2. tableView Problem
    By hrcariaga in forum Newbie
    Replies: 5
    Last Post: 7th February 2008, 08:29
  3. tableview model view problem
    By skuda in forum Qt Programming
    Replies: 5
    Last Post: 3rd December 2007, 14:02
  4. Info about QSystemTrayIcon
    By yogeshm02 in forum Qt Programming
    Replies: 2
    Last Post: 13th December 2006, 14:20
  5. QGraphicsItem problem - how to save items info ??
    By aamer4yu in forum Qt Programming
    Replies: 3
    Last Post: 17th October 2006, 12:17

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.