Results 1 to 6 of 6

Thread: QStandardItem checkbox signals

  1. #1
    Join Date
    Dec 2016
    Posts
    37
    Qt products
    Qt5
    Platforms
    Windows

    Default QStandardItem checkbox signals

    Hello.

    I've got a QTreeView with a column having QStandardItem, which is set as a checkbox.

    How do I get notified for checkbox clicks?
    In other words, how do I connect to checkbox's signals? My model where I set the QStandardItem to checkable is not subclassed from QObject.

    Thanks.

    t

  2. #2
    Join Date
    Jan 2011
    Posts
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QStandardItem checkbox signals

    It means that you use delegate in model/view("which is set as a checkbox")?
    I thought that you should connect checkbox's signal in your delegate.

  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QStandardItem checkbox signals

    Quote Originally Posted by tvj4218 View Post
    Hello.

    I've got a QTreeView with a column having QStandardItem, which is set as a checkbox.

    How do I get notified for checkbox clicks?
    In other words, how do I connect to checkbox's signals? My model where I set the QStandardItem to checkable is not subclassed from QObject.

    Thanks.

    t
    I think you meant QTreeWidget, and to receive the signal your model (as you call it) must inherit from QObject.

    Connect to QTableWidget's itemClicked(QTableWidgetItem * item) signal, and get item's checkState()
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  4. #4
    Join Date
    Dec 2016
    Posts
    37
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QStandardItem checkbox signals

    The itemClicked signal gets generated even when the user clicks on the cell containing the checkbox and not the checkbox itself. I only want a signal when the user clicks on the checkbox. Is there a way to do that?

    Thanks.

    t

  5. #5
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QStandardItem checkbox signals

    No, but you can check the checkbox status, anyway.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  6. #6
    Join Date
    Dec 2016
    Posts
    37
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QStandardItem checkbox signals

    The checkbox status is already changed by the time you get to the slot, so end up getting the new checkbox status.

Similar Threads

  1. Replies: 6
    Last Post: 27th October 2015, 12:50
  2. Get checkbox of QStandardItem
    By Neptilo in forum Qt Programming
    Replies: 8
    Last Post: 7th December 2014, 04:52
  3. Replies: 4
    Last Post: 1st June 2011, 14:54
  4. Replies: 1
    Last Post: 24th October 2010, 11:09
  5. QThread and signals (linux/UNIX signals not Qt Signals)
    By Micawber in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2007, 22:18

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.