Results 1 to 5 of 5

Thread: Interactive Widget with QListview

  1. #1
    Join Date
    Feb 2015
    Location
    Cologne/Germany
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Interactive Widget with QListview

    Dear fellow Qt-Devs,

    i am working on a QListView using custom Widgets and a custom delegate. Sadly, i can't figure out how i can react on user input on those widgets.
    The ListView is used for dropping files into the list. Inside the list, each file is represented by my custom widget and is supposed to offer stuff like "add notes", "add associated files" etc. As far as i could see is that i shouldn't use a QListView as it is just for viewing. But if i'd use a QListWidget i could not take advantage of Model/View Programming as it doesn't support a custom model. Is there even a way to accomplish this? Or am i just totally thinking into the wrong direction?

    I've already read a ton of threads but couldn't find any solution.
    Any help here is really appreciated.

    Thanks,
    René

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Interactive Widget with QListview

    QListView QItemDelegate are intended to be used while editing an item in the view, if you need the custom widget to be displayed all the time and provide an interface to edit the item as well, then you better implement a custom listview / listwidget.

    A better solution would be allow the "add notes", "add associated files" etc. feature in edit mode only, that way you can simply use QListView, custom delegates and custom editors etc..
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Feb 2015
    Location
    Cologne/Germany
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Interactive Widget with QListview

    A better solution would be allow the "add notes", "add associated files" etc. feature in edit mode only, that way you can simply use QListView, custom delegates and custom editors etc..
    Could you elaborate this a bit more? I am super new to Qt and sadly don't really understand what you mean here.
    For my current understanding every ModelItem is represented through a delegate with a widget (wich is a custom widget containing other widgets (see image attached)) in the ListView.

    Is there a way to have the whole widget as an editor and how can i create it? How do i make a widget being in "edit mode"?

    Thanks,
    René

    Screen Shot 2015-02-23 at 11.00.17.png

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Interactive Widget with QListview

    Is there a way to have the whole widget as an editor and how can i create it?
    Yes, use custom editor re-implmenting QStyledItemDelegate::createEditor(), and return what erver widget you want.

    How do i make a widget being in "edit mode"?
    This custom widget will be visible only while editing the item. Please see setEditTriggers
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  5. The following user says thank you to Santosh Reddy for this useful post:

    renevolution (23rd February 2015)

  6. #5
    Join Date
    Feb 2015
    Location
    Cologne/Germany
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Interactive Widget with QListview

    I just understood the editor stuff.
    Thanks a lot man. Really really helpful.

Similar Threads

  1. smal, non-rectangular interactive widget approaches
    By jcbikeski in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2011, 21:53
  2. Multi Widget focus problem with QListView in s60
    By ericleopard in forum Qt Programming
    Replies: 0
    Last Post: 11th July 2011, 04:29
  3. Display widget as items in a QListView
    By remy_david in forum Qt Programming
    Replies: 0
    Last Post: 10th January 2011, 10:23
  4. add custom widget items to QListView or QListWidget
    By yazwas in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2010, 22:36
  5. Replies: 2
    Last Post: 18th February 2010, 15:05

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.