Results 1 to 9 of 9

Thread: Default Item View classes and returning data from model

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2008
    Posts
    18
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Default Item View classes and returning data from model

    Awesome , this was exactly what i wanted
    The sibling thingie makes things much easier but its good to know how to sort it out the way i was trying so i know my mistake

    Thank you

  2. #2
    Join Date
    Nov 2008
    Posts
    18
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Default Item View classes and returning data from model

    Is there any way to set some of the colums of my model to not be editable ?
    Also my second column contains double variables. When you click to it you get a QDoubleSpinBox but it only allows 2 decimals ! How can i change that to lets say 5 ?

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

    Default Re: Default Item View classes and returning data from model

    Quote Originally Posted by xerionn View Post
    Is there any way to set some of the colums of my model to not be editable ?
    Yes, reimplement QAbstractItemModel::flags() for your model and make sure ItemIsEditable is not returned for indexes from those columns.

    Also my second column contains double variables. When you click to it you get a QDoubleSpinBox but it only allows 2 decimals ! How can i change that to lets say 5 ?
    Reimplement either QAbstractItemDelegate::createEditor() or QAbstractItemDelegate::setEditorData().

  4. #4
    Join Date
    Feb 2009
    Posts
    51
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Default Item View classes and returning data from model

    Quote Originally Posted by wysota View Post
    Yes, reimplement QAbstractItemModel::flags() for your model and make sure ItemIsEditable is not returned for indexes from those columns.



    Reimplement either QAbstractItemDelegate::createEditor() or QAbstractItemDelegate::setEditorData().
    Hi Wysota,

    Sorry to bug you, but I've been trying to use a QtreeView with checkboxes enclosed for each item with not much progress. I followed some thread in the forum and reimplement the flags method in my model class to include ItemIsUserCheckable. Now I can see the checkboxes appear next to each item in the tree. However, I cannot check or uncheck the checkboxes at all. I see some people advice that I should implement the setData() method in my model class but I have no clue on how to do that. Could you shed some light here?

    Thanks a lot
    Sincerely,

    Wieland J.

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

    Default Re: Default Item View classes and returning data from model

    What is the base class of your model?
    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. Item View classes and returning data !
    By xerionn in forum Newbie
    Replies: 3
    Last Post: 16th January 2009, 08:52

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.