Is it possible to select/unselect QChecBox by passing th mouse over the labels?

  pyqt5, python, qcheckbox

I’m trying to select/unselect Qcheckbox by clicking on a label and moving the mouse on others Checkboxes

enter image description here

What I would like is, for example, click on the ‘0’ and maintaning the mouse clicked and move it down on the ‘1’, ‘2’… by moving on those checkboxes their must change their value (True to False).
I don’t understand how use the mouseMoveEvent.

I made a minimal code to strat with

import vtk
import sys

from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *

class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__()
        self.centralWidget = QWidget()
        self.setCentralWidget(self.centralWidget)
        self.mainHBOX = QVBoxLayout()

        self.CB_list = []
        for i in range(20):
            CB = QCheckBox(str(i))
            CB.setChecked(True)
            self.CB_list.append(CB)
            self.mainHBOX.addWidget(CB)



        self.centralWidget.setLayout(self.mainHBOX)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MainWindow()
    window.show()
    sys.exit(app.exec_())

Source: Python Questions

LEAVE A COMMENT