Results 1 to 5 of 5

Thread: A problem about QAbstractItemView::EditTriggers

  1. #1
    Join Date
    Oct 2011
    Location
    CHINA
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: A problem about QAbstractItemView::EditTriggers

    Hi everyone~
    I used a ComboBox with checkboxes as its items in my program, this checkbox is inherited from QStyledItemDelegate.
    now I wanna check these checkboxes, but I used setEditTriggers(CurrentChanged) to initiate item editing. And of course
    this will not work when I put only one checkbox in the combobox. So is there any way to initiate item editing when I hover
    my mouse on the checkbox? Or how can I make it work even there is only one checkbox in the combobox?
    Thanks a lot!

    QAbstractItemView::SelectedClicked will work but click twice on a checkbox seems weird ~~

  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: A problem about QAbstractItemView::EditTriggers

    I don't understand what problem you have however I can answer your question. If you want to initiate editing upon hover then simply intercept proper mouse event (you'll need mouse tracking enabled) and call edit(). But before doing that think if it is necessary. If all you want is checkboxes in items then the best way is to use Qt::ItemIsUserCheckable in your model. Then the default delegate will render a checkbox for your item and provide means of checking and unchecking it.
    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
    Oct 2011
    Location
    CHINA
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: A problem about QAbstractItemView::EditTriggers

    Thank you for replying! Sorry I'm not expressing myself clearly .. here is the combobox I used : http://da-crystal.net/2008/06/checkbox-in-qcombobox/ my problem is , if there is a single checkbox , I can not check it.

  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: A problem about QAbstractItemView::EditTriggers

    Yeah, that's a poor implementation of a checkable combobox. I suggest you use the approach I proposed instead. I cannot help you with this faulty code.
    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
    Oct 2011
    Location
    CHINA
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: A problem about QAbstractItemView::EditTriggers

    Thanks, I solved it using a QStandardItemModel with its flags(const QModelIndex& index) returns QStandardItemModel::flags(index) | Qt::ItemIsUserCheckable;

Similar Threads

  1. QAbstractItemView style problem
    By QAlex in forum Qt Programming
    Replies: 0
    Last Post: 10th December 2009, 10:53
  2. Replies: 3
    Last Post: 26th November 2009, 18:28
  3. Replies: 2
    Last Post: 26th February 2009, 10:12
  4. [QListWidget] problem with editTriggers
    By Macok in forum Qt Programming
    Replies: 4
    Last Post: 17th February 2009, 19:35
  5. QAbstractItemView problem
    By Kostanev in forum Qt Programming
    Replies: 4
    Last Post: 13th September 2007, 22:32

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.