Results 1 to 4 of 4

Thread: Is a Delegate a Widget?

  1. #1
    Join Date
    Nov 2010
    Posts
    22
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Is a Delegate a Widget?

    In order to simulate a right click within a table cell with qtest::mouseclick I need to get a QWidget* pointer from that cell.

    The cell is from a QTableView so I do not have the "cellWidget" function that I used to have with QTableWidget. The view has custom delegates, so using a QModelIndex I can retrieve the delegates. indexWidget(...) allways returns 0.

    My problem is that I need the QWidget* of the cell being displayed (not the editor widget). I am confused because a delegate is a QObject and not a QWidget.

    So to make this question easy:

    How can I get the QWidget* for the cell of a table view (not the editor widget) ???

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Is a Delegate a Widget?

    That's the whole point behind view and delegates: there aren't widgets... What happens if you use the pointer to the view with a proper position?

  3. The following user says thank you to Lykurg for this useful post:

    frank100 (12th August 2011)

  4. #3
    Join Date
    Nov 2010
    Posts
    22
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Is a Delegate a Widget?

    well, I still need a widget to call the qtest::mouseClick. I can still use the whole table view as the widget, and I noticed there is an optional QPoint parameter

    If I am not mistaken, the X and Y of QPoint are pixels, not cell offsets, right?

    I need the opposite of indexAt(), I am thinking in combining rowViewportPosition() and columnViewPortPosition() to translate the cell coordinates to the qPoint I need.

    Is that the best way to emulate that right-click with qtest:mouseclick for a table view ???

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Is a Delegate a Widget?

    Quote Originally Posted by frank100 View Post
    I need the opposite of indexAt(), I am thinking in combining rowViewportPosition() and columnViewPortPosition() to translate the cell coordinates to the qPoint I need.
    QAbstractItemView::visualRect() as mentioned in QAbstractItemView::indexAt()

  6. The following user says thank you to ChrisW67 for this useful post:

    frank100 (12th August 2011)

Similar Threads

  1. Item Delegate - Relay a signal to editor widget
    By LynneV in forum Qt Programming
    Replies: 3
    Last Post: 5th July 2010, 17:36
  2. Replies: 3
    Last Post: 5th April 2010, 22:20
  3. Replies: 5
    Last Post: 19th September 2009, 12:45
  4. Replies: 1
    Last Post: 22nd October 2007, 03:04
  5. Creating advanced widget in a delegate.
    By bunjee in forum Qt Programming
    Replies: 8
    Last Post: 5th February 2007, 09:09

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.