Results 1 to 3 of 3

Thread: QTableView error

  1. #1
    Join Date
    Dec 2009
    Location
    New Zealand
    Posts
    54
    Thanks
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default QTableView error

    Hi,

    I have the following code which I am trying to get working so I can understand how the QTableView class works.. However I am getting an error message that I don't understand

    Qt Code:
    1. QTableView *channelsView = new QTableView();
    2. for (int row = 0; row < 4; ++row) {
    3. for (int column = 0; column < 4; ++column) {
    4. QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
    5. model.setItem(row, column, item);
    6. }
    7. } channelsView->setModel(model);
    To copy to clipboard, switch view to plain text mode 

    Error message:

    Qt Code:
    1. error: request for member `setItem' in `model', which is of non-class type `QStandardItemModel*'
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance

  2. #2
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTableView error

    Try this:
    model->setItem(row, column, item);

  3. The following user says thank you to boudie for this useful post:

    Ferric (10th January 2010)

  4. #3
    Join Date
    Dec 2009
    Location
    New Zealand
    Posts
    54
    Thanks
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableView error

    Thanks, I kick myself for not spotting that!

Similar Threads

  1. no compile error, but error on run with QMenu QAction
    By sincnarf in forum Qt Programming
    Replies: 4
    Last Post: 4th May 2011, 11:05
  2. Replies: 2
    Last Post: 26th November 2009, 04:45
  3. Replies: 1
    Last Post: 25th October 2008, 19:18
  4. Error format a cell in QTableView
    By estanisgeyer in forum Qt Programming
    Replies: 3
    Last Post: 4th September 2008, 14:22
  5. ERROR:: QPainter: Internal error; no available GC
    By Krishnacins in forum Qt Programming
    Replies: 2
    Last Post: 8th March 2006, 06:05

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.