Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to get signal of button from QListWidgetItem



  • How to get signal of button from QListWidgetItem, that was set using setItemWidget?

    I have got listWidget, that contains QListWidgetItem(s).

    On each of them I have got 3 buttons.

    Q. I have to distinguish what button sent the signal in mainwindow.cpp



  • @LISP
    The fact that you added the buttons into a QListWidgetItem with setItemWidget() is neither here nor there. You attach the buttons' signals as you would from anywhere. If you need to know which of the three buttons emitted the signal, or which list item the emitting button was in, it is up to you to pass the information in the connect(), e.g. by using a lambda with a suitable parameter.



  • @LISP
    The fact that you added the buttons into a QListWidgetItem with setItemWidget() is neither here nor there. You attach the buttons' signals as you would from anywhere. If you need to know which of the three buttons emitted the signal, or which list item the emitting button was in, it is up to you to pass the information in the connect(), e.g. by using a lambda with a suitable parameter.


  • Lifetime Qt Champion

    @LISP Maybe you should use https://doc.qt.io/qt-5/qbuttongroup.html instead?



  • How many items will this QListWidget have, roughly?


Log in to reply