Results 1 to 1 of 1

Thread: [Bug Report?] Star Delegate Example

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

    Default [Bug Report?] Star Delegate Example

    Hi Trolls,

    I'm a great fan of Qt and I always try to build my graphical interfaces with Qt Platform.

    In a new project a needed to do something close to the custom item delegation in "star delegate example" and I got frustrated as some of mouse events were not handled correctly in my editor widget subclass (it was not trivial to find that this was the problem).

    I realize from debugging, even from the code of "star delegate example" and at least in my Windows 7 with Visual Studio C++ environment, that the only event that behave correctly in StarEditor.cpp was mousemoveevent(). I have no idea why it is enough to do the delegate work well alone. But the point is that no StarEditor::mousereleaseevent(), StarEditor::editingFinished(), and StarDelegate::commitAndCloseEditor() was ever called or emitted no matter what interaction I did on QTableWidget.

    I googled, learned and searched a lot for two days but nothing related to this. So, almost giving up, I finally found the Qt::StrongFocus policy.

    I fixed "Star Delegate Example" by changing the following code in StarDelegate.cpp:

    Qt Code:
    1. QWidget *StarDelegate::createEditor(QWidget *parent,
    2. const QStyleOptionViewItem &option,
    3. const QModelIndex &index) const
    4.  
    5. {
    6. if (index.data().canConvert<StarRating>()) {
    7. StarEditor *editor = new StarEditor(parent);
    8. connect(editor, SIGNAL(editingFinished()),
    9. this, SLOT(commitAndCloseEditor()));
    10.  
    11. // As we like to say in Brazil: the jump of the cat
    12. editor->setFocusPolicy(Qt::StrongFocus);
    13.  
    14. return editor;
    15. } else {
    16. return QStyledItemDelegate::createEditor(parent, option, index);
    17. }
    18. }
    To copy to clipboard, switch view to plain text mode 

    This worked also for my project.

    Could you confirm that this was a bug in "Star Delegate Example"? And if so, could you please add this in the next released docs?


    Thanks and keep up the good work!


    --
    Juarez Paulino

  2. The following 2 users say thank you to juarez for this useful post:

    soughless (15th July 2013)

Similar Threads

  1. Report generator
    By mak_user in forum General Programming
    Replies: 6
    Last Post: 13th October 2015, 12:36
  2. Report library for QT
    By blackliteon in forum Qt Programming
    Replies: 5
    Last Post: 20th October 2014, 09:23
  3. Star Delegate Example
    By graciano in forum Qt Programming
    Replies: 5
    Last Post: 9th February 2010, 16:55
  4. Replies: 0
    Last Post: 17th November 2009, 21:59
  5. QT report
    By triperzz in forum Qt Programming
    Replies: 3
    Last Post: 25th February 2008, 18:58

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.