Results 1 to 2 of 2

Thread: Interaction with a widget that is rendered to display data in a model

  1. #1
    Join Date
    May 2010
    Posts
    4
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Interaction with a widget that is rendered to display data in a model

    Hi!

    I've got a custom model and a custom delegate. The delegate (for Qt.DisplayRole) instantiates a widget with a label and a button. See the attached screenshot for visualization: screenshot.png

    If the widget is shown f.ex. in a listview I cannot press the button. Is there a way that I can interact with a control on the widget if it is not shown in edit-mode?

    The other attachment is a show case for the issue in PyQt code: showcase_listview_mouse.py

    Thanks in advance!

  2. #2
    Join Date
    May 2010
    Posts
    4
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Interaction with a widget that is rendered to display data in a model

    Solved, thanks. The trick is to use QAbstractItemView.openPersistentEditor(index) as render just gives the pixmaps of the widget without functionality. So one has to implement the createEditor and an empty setModelData method in the delegate.
    However, if one does that for many items it gets slow. For me it doesn't matter since I anyway just wanted the button to show up if the mouse hovers over it, so its just one persistent editor

Similar Threads

  1. Replies: 9
    Last Post: 14th February 2013, 20:39
  2. Replies: 8
    Last Post: 6th May 2010, 12:17
  3. QListView does not display its model
    By mtrpoland in forum Qt Programming
    Replies: 1
    Last Post: 22nd February 2008, 20:31
  4. Replies: 1
    Last Post: 16th January 2008, 12:48
  5. Interaction between QT/Embedded and LCD display device
    By mahe2310 in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 22nd February 2006, 10:37

Tags for this Thread

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.