How to use QStyleSheet with actionButtons?

More
22 Oct 2024 15:01 - 22 Oct 2024 15:11 #312868 by bladekel
I'm trying to create custom qui with QtDesigner.
I have an interesting problem with actionButton.
I added an actionButton to my MainWidget,and set Action > Machine Control > Home
So far everything worked as it should.. I pressed the button and it started to homing...
After that I wanted to add color change to my Home button with sytlesheet
ActionButton[isHomed=false]{
background-color: rgb(61, 56, 70);
}
ActionButton[isHomed=true]{
background-color: rgb(51, 209, 122);
}



I tried both isHomed,isAllHomed,is_homed_status and is_joint_homed_status...

Also I tried for estop button, machine on button... All the same...
The button action worked but the stylesheet not worked.

My QtDesigner version is 5.15.8, linuxcnc 2.9.3, and working on raspberry pi5 ....

And here is the xml code part of actionButton...
               <widget class="ActionButton" name="actionbutton_8">
                <property name="minimumSize">
                 <size>
                  <width>80</width>
                  <height>80</height>
                 </size>
                </property>
                <property name="maximumSize">
                 <size>
                  <width>80</width>
                  <height>80</height>
                 </size>
                </property>
                <property name="styleSheet">
                 <string notr="true">ActionButton[isHomed=false]{
background-color: rgb(61, 56, 70);
}
ActionButton[isHomed=true]{
background-color: rgb(51, 209, 122);
}</string>
                </property>
                <property name="text">
                 <string/>
                </property>
                <property name="icon">
                 <iconset resource="../../../linuxcnc/configs/my-mill/gui/resource.qrc">
                  <normaloff>:/iconlar/pngIconlar/home.png</normaloff>:/iconlar/pngIconlar/home.png</iconset>
                </property>
                <property name="iconSize">
                 <size>
                  <width>60</width>
                  <height>60</height>
                 </size>
                </property>
                <property name="checkable">
                 <bool>false</bool>
                </property>
                <property name="indicator_option" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="indicator_HAL_pin_option" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="indicator_status_option" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="checked_state_text_option" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="python_command_option" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="on_color" stdset="0">
                 <color>
                  <red>255</red>
                  <green>0</green>
                  <blue>0</blue>
                 </color>
                </property>
                <property name="shape_option" stdset="0">
                 <number>2</number>
                </property>
                <property name="off_color" stdset="0">
                 <color>
                  <red>0</red>
                  <green>0</green>
                  <blue>0</blue>
                 </color>
                </property>
                <property name="indicator_size" stdset="0">
                 <double>0.300000000000000</double>
                </property>
                <property name="circle_diameter" stdset="0">
                 <number>10</number>
                </property>
                <property name="right_edge_offset" stdset="0">
                 <number>0</number>
                </property>
                <property name="top_edge_offset" stdset="0">
                 <number>0</number>
                </property>
                <property name="corner_radius" stdset="0">
                 <double>5.000000000000000</double>
                </property>
                <property name="height_fraction" stdset="0">
                 <double>0.300000000000000</double>
                </property>
                <property name="width_fraction" stdset="0">
                 <double>0.900000000000000</double>
                </property>
                <property name="true_state_string" stdset="0">
                 <string>True</string>
                </property>
                <property name="false_state_string" stdset="0">
                 <string>False</string>
                </property>
                <property name="true_python_cmd_string" stdset="0">
                 <string>print(&quot;true command&quot;)</string>
                </property>
                <property name="false_python_cmd_string" stdset="0">
                 <string>print(&quot;false command&quot;)</string>
                </property>
                <property name="invert_the_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_paused_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_estopped_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_on_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_idle_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_homed_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_flood_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_mist_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_block_delete_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_optional_stop_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_joint_homed_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_limits_overridden_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_manual_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_mdi_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_auto_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_spindle_stopped_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_spindle_fwd_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="is_spindle_rev_status" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="joint_number_status" stdset="0">
                 <number>0</number>
                </property>
                <property name="isHomed" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="isAllHomed" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="home_action" stdset="0">
                 <bool>true</bool>
                </property>
                <property name="template_label_option" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="joint_number" stdset="0">
                 <number>-1</number>
                </property>
                <property name="incr_imperial_number" stdset="0">
                 <double>0.010000000000000</double>
                </property>
                <property name="incr_mm_number" stdset="0">
                 <double>0.025000000000000</double>
                </property>
                <property name="incr_angular_number" stdset="0">
                 <double>-1.000000000000000</double>
                </property>
                <property name="toggle_float_option" stdset="0">
                 <bool>false</bool>
                </property>
                <property name="float_num" stdset="0">
                 <double>0.300000000000000</double>
                </property>
                <property name="float_alt_num" stdset="0">
                 <double>50.000000000000000</double>
                </property>
                <property name="view_type_string" stdset="0">
                 <string>P</string>
                </property>
                <property name="command_text_string" stdset="0">
                 <string/>
                </property>
                <property name="ini_mdi_number" stdset="0">
                 <number>0</number>
                </property>
                <property name="textTemplate" stdset="0">
                 <string>%1.3f in</string>
                </property>
                <property name="alt_textTemplate" stdset="0">
                 <string>%1.2f mm</string>
                </property>
               </widget>
Last edit: 22 Oct 2024 15:11 by bladekel.

Please Log in or Create an account to join the conversation.

More
23 Oct 2024 17:26 #312988 by bkt
for first I'm not QtVCP programmer .... but supicius is thebackground-color: rgb(51, 209, 122);

is not right features .... or not write in right manner .... here a normal qtcreatod stylesheet code:
QPushButton {font-weight: bold;color: #5E749C; border: 3px solid #1c5e12;border-radius: 5px;background: rgba(242, 242, 242, 150); background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #FFFFFD, stop: 0.3 #96ADB2);min-width: 41px;}QPushButton:pressed{font-weight: bold;color: cyan;background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #6F7E81, stop: 0.3 #DCF6FC);border-color: #27d404; border-width: 3px;}QPushButton:flat {border: none;}QPushButton:default { border-color: cyan;}

hope can help you go to in right directions ....

Please Log in or Create an account to join the conversation.

More
24 Oct 2024 04:56 - 24 Oct 2024 04:59 #313028 by cmorley
Replied by cmorley on topic How to use QStyleSheet with actionButtons?
On you actionbutton (in Designer):
Select property 'indicator_status_option'
Select property 'is_homed_status'

Then set your stylesheet, though usually one would set a specific button:
ActionButton#actionbutton_8[isAllHomed=false]{
background-color: rgb(61, 56, 70);
}
ActionButton#actionbutton_8[isAllHomed=true]{
background-color: rgb(51, 209, 122);
}
Last edit: 24 Oct 2024 04:59 by cmorley.
The following user(s) said Thank You: bkt, bladekel

Please Log in or Create an account to join the conversation.

Moderators: cmorley
Time to create page: 0.062 seconds
Powered by Kunena Forum