Results 1 to 3 of 3

Thread: Clarification about dataChanged

  1. #1
    Join Date
    Jul 2009
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Clarification about dataChanged

    Hello,

    I need an explanation about dataChanged() and beginInsertRows/endInsertRows().
    I have implemented a model using QAbstractTableModel class and the model is editable; I'm not using setData() method to update the model but my own method that add or update an item to the model.
    Can the method emit dataChanged() when item is inserted or I must use beginInsertRows/endInsertRows?
    Or do both of beginInsertRows and endInsertRows emit dataChanged()?

    Thank you a lot!
    Last edited by airbites; 29th July 2009 at 15:04.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Clarification about dataChanged

    Quote Originally Posted by airbites View Post
    Can the method emit dataChanged() when item is inserted or I must use beginInsertRows/endInsertRows?
    It must use beginInsertRows() and endInsertRows().

    Or do both of beginInsertRows and endInsertRows emit dataChanged()?
    They don't. dataChanged() is emitted only for existing indexes (there has to be some data first for it to change).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    airbites (29th July 2009)

  4. #3
    Join Date
    Jul 2009
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Clarification about dataChanged

    Thank you wysota. That really makes things clear

Similar Threads

  1. QAbstractTreeModel & dataChanged()
    By tntcoda in forum Qt Programming
    Replies: 2
    Last Post: 3rd June 2009, 00:12
  2. dataChanged does not re-sort the view
    By alex9099 in forum Qt Programming
    Replies: 2
    Last Post: 5th October 2008, 20:14
  3. questions about datachanged() in model/view programming
    By calmspeaker in forum Qt Programming
    Replies: 1
    Last Post: 8th September 2008, 23:48
  4. need some clarification on QImage and QRgb usage
    By kona in forum Qt Programming
    Replies: 5
    Last Post: 6th September 2008, 14:20

Tags for this Thread

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.