I have a list of Qt buttons like this: self.buttons = [button1, button2, button3]
When one is clicked, I want all the buttons that come before the one that was clicked in the list to change their colors.
I made a for loop to loop through the buttons and connect each one to a function that I defined, but when I click a button and the connected function runs, it does not know the order of the button in the buttons list, therefore I cannot make the other buttons change colors. I was thinking that I need to somehow pass the button's id or something to the function but couldn't figure out how to do it as I cannot pass arguments to the connected function: self.button1.clicked.connect(self.change_color)
One argument is automatically passed to the connected function by Qt itself but it is the main window and it does not help my situation:
def change_color(i):
print(i)
Output when clicked:
<__main__.Main_Window(0x6000019e0000, name="MainWindow") at 0x11df5ccc0>