Results 1 to 2 of 2

Thread: table view and model: layout signals and data changed signals

  1. #1
    Join Date
    Dec 2009
    Posts
    52
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default table view and model: layout signals and data changed signals

    Hello,

    I have a QDialog with a QTableView and a QPushButton.
    When the dialog shows up, the QTableView has 10 rows and 3 columns. It is a fixed table. However all the cells are empty except for the last column which contains a QPushButton for each row.

    Under the QTableView, there is a Run... QPushButton. Connected to the click signal of it is my run() function.

    run() calls a very long algorithm, the results of which are used to fill up the cells of the table that are still empty.

    I understand at the end of run(), I need to notify my model (used by the view) of the newly available data.

    My model inherits from QAbstractTableModel. It has overriden data(), rowcount(), columncount(), headerData().

    Am I supposed to override setData() too? Is that for "editable" just from the GUI or editable models from anywhere?
    I could just have a custom member function to update the private member containers of the model, and call it instead of calling setData() for each index individually.

    Then I need to emit a signal after that. The number of row/columns doesn't change. The sorting order of cells doesn't change. The cells just change from empty to having some numerical value.

    Do I emit dataChanged or layoutChanged? There's more than 1 layout... signal I think. Which one?

    The next step will be to run the long algorithm in another thread so that the GUI remains responsive, then when done update the model.

    Can the signal be emitted from another thread (boost::thread) or do I need to make sure I emit the signal from wherever thread the run() function of my button was executed in (I suppose this is the main thread which is the GUI thread)

    regards,

  2. #2
    Join Date
    Dec 2009
    Posts
    52
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: table view and model: layout signals and data changed signals

    any advice would be appreciated?

Similar Threads

  1. Replies: 1
    Last Post: 1st February 2010, 18:42
  2. Table view->model->set data
    By tulsi in forum Qt Programming
    Replies: 3
    Last Post: 21st April 2009, 08:36
  3. QThread and signals (linux/UNIX signals not Qt Signals)
    By Micawber in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2007, 22:18
  4. Table Model / View Problem -- Data Not Displaying
    By jhendersen in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2007, 06:45
  5. Model/View Programming -- Signals
    By KjellKod in forum Qt Programming
    Replies: 17
    Last Post: 7th February 2006, 16:36

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.