Results 1 to 2 of 2

Thread: Setting Editing Possibilities in Model/View set up

  1. #1
    Join Date
    May 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Setting Editing Possibilities in Model/View set up

    I am currently just fooling around with the Model/View architecture in preparation for working with a larger application that deals more extensively with this design. I am working on the TrackEditor example, that can be found at: http://http://www.informit.com/title/0132354160 (chapter 10) . I have extended this example to truly have a Model View architecture with a trackmodel class added, as well as a Tracks class that basically acts as a separate data source. The problem I am running into is that I cannot seem to figure out how to isolate a column in the model and remove the possibility of editing the data. I know that I need to modify the model in some way but my trackmodel class is subclassed from the QAbstractTableModel which unfortunately has limited capabilities with isolating single columns of data (as far as I can tell). I am attempting to do this using flags and the itemIsEditable but I cannot seem to find the correct syntax. I am somewhat new to Qt so any help or direction would be helpful. THANKSSS.

  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: Setting Editing Possibilities in Model/View set up

    How about:

    Qt Code:
    1. Qt::ItemFlags MyModel::flags(const QModelIndex &index) const {
    2. Qt::ItemFlags fl = QAbstractTableModel::flags(index);
    3. if(index.column()==4) fl &= ~Qt::ItemIsEditable; // clear the editable flag for column no. "4"
    4. return fl;
    5. }
    To copy to clipboard, switch view to plain text mode 
    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.


Similar Threads

  1. model/view editing question
    By KShots in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2008, 17:52
  2. Questions regarding setting up a Qt SQL Model/View
    By Methedrine in forum Qt Programming
    Replies: 3
    Last Post: 26th November 2007, 09:26

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.