Qt World Summit: Register Today!

QStandardItem setCheckable(true) & catch any signal when the user click on the checkbox

  • Hello

    In my QStrandardItemModel I add a column which all the QStandardItem have setCheckable(true).
    When the user click on an checkbox in this column, an signal is emited ?

    I need an signal to connect with my slot

    Best regards

  • 1, when setCheckable(true), the item can be checked by the user; otherwise, the user cannot check the item.
    2, maybe you can try itemChanged as you signal.
    3, also you can use QCheckBox::stateChanged ( int state )
    void QCheckBox::stateChanged ( int state ) [signal]
    This signal is emitted whenever the check box's state changes, i.e. whenever the user checks or unchecks it

  • ..

  • Helllo
    I know 1)
    I will try 2)
    For 3) how do you know the name of the checkbox in order to connect with the slot ?

    Best Regards

  • Perhaps you can use "QxtListWidget":http://libqxt.bitbucket.org/doc/0.6/qxtlistwidget.html instead? It provides a dedicated signal for this.

  • Other idea.
    In the view have the
    @void QAbstractItemView::clicked ( const QModelIndex & index ) [signal]@
    In the model check the column you use for the checkbox from the argumentlist.
    Call your slot as function and you have the same working, but with a small detour.
    So it is more the view then the model that calls the slot you want when a item is clicked.
    Hope this helps a bit.

  • re

    I'll will try first Jeroen idea.
    And after Andre idea, but I don"t have Qxt in my program, and I don't want to add only for an component

    Best regards

  • Hello
    The solution from Jeroen is perfect for my use.
    Thanks a lot everybody
    Best Regards

Log in to reply