Results 1 to 5 of 5

Thread: QTableView changing item text (signal)?

  1. #1
    Join Date
    Aug 2008
    Posts
    38
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default QTableView changing item text (signal)?

    Hello all,
    I have a simple (hopefully) question regarding QTableView. I have one in a form, and would like to get a signal from it when the text inside one of the cells changes. I have it loading with a QSqlTableModel, from an SQL database and I would like some kind of notification when the user changes one of the rows data.

    Any thoughts?
    I am using QT 4.7.4, creator 2.4, on Windows 7 32bit.
    Thanks,
    AlphaWolfXV
    Last edited by AlphaWolfXV; 27th December 2011 at 16:12.

  2. #2
    Join Date
    Mar 2011
    Location
    Russia, Lipetsk
    Posts
    17
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView changing item text (signal)?

    Hello.
    If I rigth understand you, try to use next signal of QSqlTableModel -
    void dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight )
    from Assistant:
    This signal is emitted whenever the data in an existing item changes.

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

    AlphaWolfXV (28th December 2011)

  4. #3
    Join Date
    Aug 2008
    Posts
    38
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableView changing item text (signal)?

    Thank you Kunashir, I will give that a try!

    On a related note, I have tried to subclass QItemDelegate as in the spinbox example... This does "catch" the edited text and will update the model upon "enter". However, I would like to emit a signal from the subclass (a formDirty() signal) which would let the user know they are about to change data in the sql database. (Similar to MSAccess table/form editing). Any thoughts...
    I currently added a signal void dirty(); to the subclassed h file [LineEditDelegate.h] and emit it from the cpp when the editor is called, but now I receive the error on compiling:
    passing const LineEditDelegate as 'this' argument in void LineEditDelegate::dirty() discards qualifier
    I am unclear as to what this means!
    Thanks,
    AlphaWolfXV

  5. #4
    Join Date
    Mar 2011
    Location
    Russia, Lipetsk
    Posts
    17
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView changing item text (signal)?

    Hello!
    AlphaWolfXV, for your task You may use delegate, but if use only text, it is more difficult.
    From error: I suggest Your try change const variable - LineEditDelegate.

  6. The following user says thank you to kunashir for this useful post:

    AlphaWolfXV (30th December 2011)

  7. #5
    Join Date
    Aug 2008
    Posts
    38
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableView changing item text (signal)?

    kunashir,
    Thank you for your info. I will give that a try!
    Thanks,
    AlphaWolfXV

Similar Threads

  1. changing transparency of part of a qgraphicspixmap item
    By knapshots in forum Qt Programming
    Replies: 1
    Last Post: 3rd June 2011, 11:25
  2. Changing selected QTreeView item font
    By dima1000 in forum Newbie
    Replies: 5
    Last Post: 8th October 2009, 09:28
  3. Changing font color for a single item in a QTreeView
    By Doug Broadwell in forum Qt Programming
    Replies: 1
    Last Post: 3rd November 2007, 19:14
  4. Changing selected item color in non-current window.
    By Doug Broadwell in forum Qt Programming
    Replies: 1
    Last Post: 26th August 2007, 07:09
  5. Replies: 3
    Last Post: 12th April 2006, 09:35

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.