Results 1 to 6 of 6

Thread: QAbstractItemView activated

  1. #1
    Join Date
    Jul 2007
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QAbstractItemView activated

    Hi all,

    I have a QTableView which can be edited by the user, but there is an index column that can´t have duplicated cells (each row has an unique ID).
    For this, i check the contents of the edited cell and search in the index column for it.
    The problem is that if i find duplicates, i want to revert to the previous data in that cell.
    I´ve been trying to write a QString with the cell gets active with its contents, (signal activated), but it never throws this signal... Is there other way to know when a cell gets selected??? (something like a signal for knowing when a cell gets focused)


    Thx!!!

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QAbstractItemView activated

    Perhaps you could do the validation in QAbstractItemDelegate::setModelData() or QAbstractItemModel::setData()?
    J-P Nurmi

  3. #3
    Join Date
    Jul 2007
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QAbstractItemView activated

    The validation works well, the problem is getting the old value back if the inserted one is not valid... previously I inserted a blank String with 'insertData', but i want to insert the old data back....

    J.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QAbstractItemView activated

    By doing the validation in setModelData() or setData() you could prevent invalid data from reaching the model. The previous value would remain after an editor gets closed and attempts to set invalid data.
    J-P Nurmi

  5. #5
    Join Date
    Jul 2007
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QAbstractItemView activated

    The prob. is that i dont use setData by code. The TableView is editable, so the model autoupdates (or i think so).
    Perhaps there is a signal (something like onCellFocused) that could give me a chance to store the content of the cell in other variable....
    I dont know if im clear enough (perhaps just too noob)

    J.

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QAbstractItemView activated

    Quote Originally Posted by Shaitan View Post
    The prob. is that i dont use setData by code. The TableView is editable, so the model autoupdates (or i think so).
    The data gets set to the model via aforementioned methods by the underlying model-view framework.
    J-P Nurmi

Similar Threads

  1. QomboBox - activated(), highlighted()
    By Salazaar in forum Newbie
    Replies: 10
    Last Post: 14th June 2007, 11:50
  2. Replies: 2
    Last Post: 27th February 2007, 21:06
  3. [qt-4.2] question on QAbstractItemView
    By someralex in forum Qt Programming
    Replies: 12
    Last Post: 19th December 2006, 15:41
  4. How change the DropIndicator of QAbstractItemView
    By Wan-Hi in forum Qt Programming
    Replies: 3
    Last Post: 20th March 2006, 19:58
  5. setContentsMargins in QAbstractItemView
    By Promethee in forum Qt Programming
    Replies: 2
    Last Post: 4th February 2006, 14:40

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.