Results 1 to 5 of 5

Thread: QBstractTableMode derived model, not showing in QTableView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QBstractTableMode derived model, not showing in QTableView

    Hi,

    thanks for the reply.
    First off, see if having an actual pointer to your model makes a difference instead of allocating memory for it in the setModel method; i.e.:
    QAbstractTableModelsubclass* myModel; //defined in header file as member of possibly QMainWindow
    myModel = new QQAbstractTableModelsubclass(...);
    pTable->setModel(myModel);
    I am not sure what do you mean.
    The call:
    Qt Code:
    1. pTable->setModel((QAbstractTableModel *)&m_logFile->dataModel());
    To copy to clipboard, switch view to plain text mode 
    is not allocating anything.
    m_logFile->dataModel() returns a reference to a model which is allocated and lives in m_logFile.
    At the time when I am calling pTable->setModel() the model is well allocated and filled with data, so I am not sure what you might have meant there, can you restate maybe?

    I'm not exactly sure what is happening when you make the call to setModel with your parameters (not seeing the whole code), but it looks suspicious.
    Which setModel() do you mean? my model subclass setModel() or the pTable->setModel()?
    And what exactly you find suspicious - so I can check it.

    Also, another avenue is seeing your data function, which I don't see listed in your header. This is where the table view actually gets the data for your model.
    True.
    I forgot to add it here, I will later when I am home again. (don't have the code here).
    However, as I said, my data() function is not being called by the QTableView... all though I checked to make sure my virtual implementations signatures are correct, I will have a look again.

    Thanks, and if you have more pointers, please share.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  2. #2
    Join Date
    Apr 2009
    Posts
    36
    Thanks
    1
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QBstractTableMode derived model, not showing in QTableView

    I guess what I'm saying is that it is hard to see what you are trying to do with your model. Posting the code will be helpful to evaluate why you are not seeing the model data in the table view. Otherwise, I can only guess why it's not working.

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QBstractTableMode derived model, not showing in QTableView

    Hi,

    I just ran my code on a different machine, and it works perfectly.
    No idea why on my machine it doesn't show up.

    Oh well.

    Thanks any way!
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Problem showing QTableView
    By weaver4 in forum Qt Programming
    Replies: 6
    Last Post: 23rd November 2009, 13:42
  2. Replies: 4
    Last Post: 7th August 2009, 21:09
  3. QTableView only showing data when row selected
    By Banjo in forum Qt Programming
    Replies: 2
    Last Post: 27th January 2009, 05:34
  4. QTableView showing empty fields
    By ederbs in forum Qt Programming
    Replies: 5
    Last Post: 4th October 2007, 00:30
  5. QTableView not corectly showing empty fields
    By Sergey B. in forum Qt Programming
    Replies: 4
    Last Post: 15th June 2007, 08:18

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.