Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [6.6.1] Custom control panel: possible to turn off one button (Image) when another is clicked/tapped on? Do I use States?
Forum Updated to NodeBB v4.3 + New Features

[6.6.1] Custom control panel: possible to turn off one button (Image) when another is clicked/tapped on? Do I use States?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 245 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    I.Mironov
    wrote on last edited by
    #1

    Hello, everyone. I didn't know how to summarize the topic title and still have it make sense. My question is regarding using States, or if States is the way I should go.

    For some background information, I've created my own custom touch panel (via Adobe Illustrator) to control an LED matrix where I test animations. This project will be used with Python (PySide6) and then used on my Raspberry Pi 4's touchscreen.

    I have the images set as buttons, and I've figured out how to get them to change states (On image vs Off image) when clicking on them, but what I cannot figure out (despite looking over all the documentation) is how I can also make a button (technically these are images) turn off when I click/tap on another.

    As it stands, I can click on any one of them and able to toggle them all at the same time. What I want is to also include the ability to turn off one of them if I select another. I know AbstractButton and Exclusive ONLY allows turning off one button when another is selected and does not allow toggling that same button; that is not what I want.

    Below is a link to my project, which should make it easier to see the code. Currently, I'm using only Main and main to get the basic control panel layout to work how I want before implementing the other files. led_matrix will eventually be linked in to handle the triggering of different animations and control_panelwill have its code merged into main (unless I'm overlooking the fact that I should be using its code with main in order to turn off the other button states?).

    https://github.com/ion-mironov/LED_control_panel

    JoeCFDJ 1 Reply Last reply
    0
    • I I.Mironov

      Hello, everyone. I didn't know how to summarize the topic title and still have it make sense. My question is regarding using States, or if States is the way I should go.

      For some background information, I've created my own custom touch panel (via Adobe Illustrator) to control an LED matrix where I test animations. This project will be used with Python (PySide6) and then used on my Raspberry Pi 4's touchscreen.

      I have the images set as buttons, and I've figured out how to get them to change states (On image vs Off image) when clicking on them, but what I cannot figure out (despite looking over all the documentation) is how I can also make a button (technically these are images) turn off when I click/tap on another.

      As it stands, I can click on any one of them and able to toggle them all at the same time. What I want is to also include the ability to turn off one of them if I select another. I know AbstractButton and Exclusive ONLY allows turning off one button when another is selected and does not allow toggling that same button; that is not what I want.

      Below is a link to my project, which should make it easier to see the code. Currently, I'm using only Main and main to get the basic control panel layout to work how I want before implementing the other files. led_matrix will eventually be linked in to handle the triggering of different animations and control_panelwill have its code merged into main (unless I'm overlooking the fact that I should be using its code with main in order to turn off the other button states?).

      https://github.com/ion-mironov/LED_control_panel

      JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #2

      @I-Mironov is this what you need?
      https://doc.qt.io/qt-6/qbuttongroup.html

      I 1 Reply Last reply
      0
      • JoeCFDJ JoeCFD

        @I-Mironov is this what you need?
        https://doc.qt.io/qt-6/qbuttongroup.html

        I Offline
        I Offline
        I.Mironov
        wrote on last edited by I.Mironov
        #3

        @JoeCFD No. I guess I should've specifically mentioned that I also looked into the Button group documentation (although I did originally talk about how AbstractButton and Exclusive, which are part of the Button group, will not work for me). Also, trying to make them as buttons completely screws up my entire layout for everything and I can never find helpful answers as to why, but that's a different subject for another time.

        All I want to know is if it is possible with my current setup. If yes, how do I go about it? If no, why?
        .
        .
        .
        UPDATE: I found out that it is indeed possible, and it was incredibly simple! All I had to do was include some additional onClicked handlers to set the states of the other buttons to off.

        Before:

        MouseArea {
        	anchors.fill: parent
        	onClicked: leftSignal.buttonState = (leftSignal.buttonState === 'on') ? 'off' : 'on';
        }
        

        After:

        MouseArea {
        	anchors.fill: parent
        	onClicked: {
        		rightSignal.buttonState = 'off';
        		brakeLights.buttonState = 'off';
        		parkingLights.buttonState = 'off';
        		leftSignal.buttonState = (leftSignal.buttonState === 'on') ? 'off' : 'on';
        	}
        }
        
        1 Reply Last reply
        0
        • I I.Mironov has marked this topic as solved on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved