Results 1 to 7 of 7

Thread: Better understanding of the ModelView archtecture

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2010
    Location
    Cincinnati, Ohio, USA
    Posts
    92
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3

    Question Re: Better understanding of the ModelView archtecture

    Quote Originally Posted by tbscope View Post
    I did understand your wrong. In that case, I guess you can use a file system watcher (also in the model): http://doc.qt.nokia.com/4.6/qfilesystemwatcher.html
    Again, a file system watcher is not viable, because as I stated before: outside forces can and DO change the state. Using a file system watcher would mean a service running 24/7 and this is a bit over kill. The safest and cleaned way to accurately show the user the state is to check the state on demand. So, the question remains:

    Q: In a Qt Model, how does one have one column that is dynamic upon display.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 268 Times in 268 Posts
    Wiki edits
    20

    Default Re: Better understanding of the ModelView archtecture

    Quote Originally Posted by scarleton View Post
    Q: In a Qt Model, how does one have one column that is dynamic upon display.
    A model is (or should be) dynamic by design. You don't need to do anything else but set the new data in the correct place.

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

    Default Re: Better understanding of the ModelView archtecture

    Normally, you implement your own data() method that returns the value for a given ModelIndex. It could look something like this:

    Qt Code:
    1. QVariant CalculatorTapeModel::data(const QModelIndex &index, int role) const
    2. {
    3. if (!index.isValid()) return QVariant();
    4.  
    5.  
    6. if (role == Qt::TextAlignmentRole)
    7. {
    8. ... alignment code ...
    9. }
    10.  
    11.  
    12. if (role == Qt::DisplayRole)
    13. {
    14. *** This is where you should check the state of your dynamic items ***
    15. ... return data for requested item ...
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. I need help understanding QGraphicsView
    By aarelovich in forum Qt Programming
    Replies: 13
    Last Post: 22nd July 2009, 20:02
  2. GraphicsView / ModelView Integration ???
    By travlr in forum Qt Programming
    Replies: 11
    Last Post: 8th December 2008, 10:19
  3. understanding QwtPlot::transform()
    By b.mourat in forum Qwt
    Replies: 1
    Last Post: 25th May 2008, 07:43
  4. Problems understanding QGraphicsScene
    By Bocki in forum Qt Programming
    Replies: 3
    Last Post: 15th February 2008, 12:43
  5. How customize items of ModelView?
    By istdasklar in forum Qt Programming
    Replies: 3
    Last Post: 28th March 2007, 18:08

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.