Results 1 to 10 of 10

Thread: Nested delegates in a QListWidget

  1. #1
    Join Date
    Apr 2008
    Posts
    39
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Nested delegates in a QListWidget

    Hi.

    The delegate of a list item is a table. So far, so good. The tables cells are also editable and use a delegate (line edit).

    Whenever I'm in that second level delegate and hit "up" or "down", den listwidget enters a strange state where every "tab" or "arrow" hit crashes the program.

    On focus loss, only one level of editing will be closed also.

    What do I have to check if I want to use such nested delegates correctly?

    Bye

  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: Nested delegates in a QListWidget

    Could you rephrase your question? Try describing it using simple sentences and please give more details. A code snippet might help greatly as well.

    By the way, you are incorrectly referring to the term 'delegate'. The delegate is an invisible object that provides service to a view and paints items on its behalf. Usually there is one delegate for the whole view, even if you want different items to be handled differently. I don't know what you did in your delegate(s) but you probably have a design flaw somewhere.
    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.


  3. #3
    Join Date
    Apr 2008
    Posts
    39
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Nested delegates in a QListWidget

    Here is a screenshot with the "nested" editing active.



    If you hit the down-arrow, both edit modes will not be closed correctly.

    Bye

  4. #4
    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: Nested delegates in a QListWidget

    You have a table widget inside a list widget? Wouldn't it be easier using a QTextEdit? Constraining edit to a single word should not pose a problem (if that's what you want).
    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.


  5. #5
    Join Date
    Apr 2008
    Posts
    39
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Nested delegates in a QListWidget

    And disable line breaks? The content is arranged in syllables already. A QTextEdit is no possibility.

    Bye

  6. #6
    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: Nested delegates in a QListWidget

    Quote Originally Posted by youkai View Post
    And disable line breaks?
    Sure, why not?

    The content is arranged in syllables already. A QTextEdit is no possibility.
    I don't see the problem. QTableWidget inside a QListWidget is probably one of the worst possible solutions. A simple custom widget would be much better here than this construction but I still think you can use QPlainTextEdit if you reimplement its keyPressEvent and disable some of the keys. If not then QListWidget with a custom delegate is an option. So is a QListWidget without a custom delegate but with items properly laid out which should be possible by enabling wrapping.
    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.


  7. #7
    Join Date
    Apr 2008
    Posts
    39
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Nested delegates in a QListWidget

    Thanks for your input. I will think about it. My problem was solved by disabling Key_UP and Key_DOWN while in edit mode.

    Your ideas are quite nice but I think the usability of the result would not be so good. Well, I will think about it.

    Bye

  8. #8
    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: Nested delegates in a QListWidget

    Your choice. Your current solution is completely unscalable and QListWidget is practically unused at all. You might have used QScrollArea instead of it as well. To me it seems you are emulating a text editor/browser widget with two nested widgets serving for a completely different purpose. I don't how it relates to usability But that's your choice, no problem with me.
    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.


  9. #9
    Join Date
    Apr 2008
    Posts
    39
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Nested delegates in a QListWidget

    Unscalable? Well, there won't be much text - just the lyrics of one song - not that much. I use the QListWidget for selecting a line - not "unused" at all. Or what do you mean?

    The use-case is to offer a more convenient way for editing this kind of text file:

    Qt Code:
    1. ...
    2. : 185 2 10 ter
    3. : 189 5 10 an,
    4. - 196 222
    5. : 242 3 8 der
    6. : 247 3 8 hat
    7. : 252 2 8 so
    8. : 255 5 8 gar
    9. : 263 3 5 ein
    10. * 270 6 13 Au
    11. * 278 14 10 to.
    12. - 294 329
    13. : 349 4 12 Wa
    14. : 354 4 12 rum
    15. : 360 4 13 gehst
    16. : 365 3 10 du
    17. : 369 4 10 nicht
    18. ...
    To copy to clipboard, switch view to plain text mode 

    You must not destroy the syllable itself but make minor corrections like adding/remove a whitespace or fix spelling issues.

    Do you have a better approach in mind?

    Bye
    Last edited by youkai; 7th April 2009 at 07:22.

  10. #10
    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: Nested delegates in a QListWidget

    To me the perfect solution is to use a QTableWidget. Either a standard one or a modified one with visualRect (and probably some other methods as well) changed so that you can have different widths of columns in different rows if you need that. A feasible solution is also to implement a completely custom view so that you have a bit more control over what is going on. The view is really simple so it should take no more than an hour to implement it. Once you have visualRect() and indexAt() implemented, the rest will build upon them.
    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. QListWidget transparent background or pixmap
    By wdezell in forum Qt Programming
    Replies: 6
    Last Post: 6th March 2009, 17:53
  2. Segmentation Faul using addItem (QListWidget)
    By gnusar in forum Qt Programming
    Replies: 3
    Last Post: 8th November 2008, 09:27
  3. how to sync a QTreeWidget and a QListWidget?
    By zl2k in forum Qt Programming
    Replies: 2
    Last Post: 5th September 2008, 20:55
  4. QListWidget Problem
    By pmabie in forum Qt Programming
    Replies: 1
    Last Post: 7th October 2007, 06:52
  5. Replies: 13
    Last Post: 15th December 2006, 11: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.