Jump to content

How to specify the Icon file in a UM.ToolbarButton QT6 ?


Go to solution Solved by Cuq,

Recommended Posts

Posted · How to specify the Icon file in a UM.ToolbarButton QT6 ?

Hello,

 

I'm trying to improve the look of my toolbar plugin interface, And I don't find the solution to specify the Icon File for a UM.Button ?

Actual code :

 

            Button
            {
                id: tubeButton;
                text: catalog.i18nc("@label", "Tube")
                display: AbstractButton.IconOnly
                width: UM.Theme.getSize("button").width
                height: UM.Theme.getSize("button").height	
                icon.source: "type_tube.svg"
                checkable:true
                onClicked: setSType('tube')
                checked: UM.ActiveTool.properties.getValue("SType") === 'tube'
                ToolTip.delay: 500
                ToolTip.timeout: 5000
                ToolTip.visible: hovered
                ToolTip.text: qsTr("Tube as custom support")
                z: 5 // Profondeur
            }

 

Expected new definition

 

            UM.ToolbarButton
            {
                id: tubeButton;
                text: catalog.i18nc("@label", "Tube")
                icon.source: "type_tube.svg"
                onClicked: setSType('tube')
                checked: UM.ActiveTool.properties.getValue("SType") === 'tube'
                z: 5 // Profondeur
            }

 

Any advice will be welcome

 

Cuq

  • Link to post
    Share on other sites

    • Solution
    Posted (edited) · How to specify the Icon file in a UM.ToolbarButton QT6 ?

    OK Got it !

     

    UM.ToolbarButton
    {
      id: customButton;
      text: catalog.i18nc("@label", "custom");
      toolItem: UM.ColorImage
      {
        source: Qt.resolvedUrl("type_custom.svg")
        color: UM.Theme.getColor("icon")
      }
      property bool needBorder: true;
      checkable:true;
      onClicked: setSType('custom');
      checked: UM.ActiveTool.properties.getValue("SType") === 'custom';
      z: 1; // Profondeur
    }

     

    Edited by Cuq
    • Like 1
    Link to post
    Share on other sites

    Posted · How to specify the Icon file in a UM.ToolbarButton QT6 ?

    I use the UM theme.  That looks fine to me.

    I do have some critiques though as I've used it quite a bit for blocking supports.  After you get it straightened out I'll look again at the re-worked version and send you a message.  Off the top of my head - I've never understood the Max Size box.

  • Link to post
    Share on other sites

    Posted · How to specify the Icon file in a UM.ToolbarButton QT6 ?
    13 minutes ago, GregValiant said:

    I've never understood the Max Size box.

     

    Max Size must be used with the Angle Parameter. If you specify a value for Angle this parameter will limit the size of your support to this dimension .

     

    Ie Max Size = 0 and Angle = 20°

    image.thumb.png.f9dc98be124e4bcbe8a878f1e9076c23.png

     

    A value of 30 mm will limite the diameter of the support.

     

    image.thumb.png.bd22163bbda57476ca114857681feb8c.png

  • Link to post
    Share on other sites

    Posted · How to specify the Icon file in a UM.ToolbarButton QT6 ?

    Compact Style :

    image.png.9103cc4e1ebc09f6e68ab92cb78315d5.png

  • Link to post
    Share on other sites

    Posted (edited) · How to specify the Icon file in a UM.ToolbarButton QT6 ?

    By The way I'm still fighting with this QML file , I have some difficulties to reduce this space when the CheckBox are not visible. That's certainly something stupid but as I'm not an expert If someone can give me an advice :

     

    The issue  this space 

    image.png.6182fc65ac0bf8e443b9f50f529bbd5c.png

     

    The source code : https://github.com/5axes/CustomSupportCylinder/blob/master/qml_qt6/CustomSupport.qml

    Edited by Cuq
  • Link to post
    Share on other sites

    Posted · How to specify the Icon file in a UM.ToolbarButton QT6 ?

    I'm sure there is a simplest solution, but nothing better for the moment.

     

    		width: childrenRect.width
    		height: !freeformButton.checked && !abutmentButton.checked  ? 0 : (abutmentButton.checked ? (UM.Theme.getSize("setting_control").height*2+UM.Theme.getSize("default_margin").height): childrenRect.height)
    		anchors.leftMargin: UM.Theme.getSize("default_margin").width
    		anchors.top: textfields.bottom
    		anchors.topMargin: UM.Theme.getSize("default_margin").height

     

  • Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Our picks

      • UltiMaker Cura 5.9 stable released!
        Here comes Cura 5.9 and in this stable release we have lots of material and printer profiles for UltiMaker printers, including the newly released Sketch Sprint. Additionally, scarf seams have been introduced alongside even more print settings and improvements.  Check out the rest of this article to find out the details on all of that and more
          • Like
        • 5 replies
      • Introducing the UltiMaker Factor 4
        We are happy to announce the next evolution in the UltiMaker 3D printer lineup: the UltiMaker Factor 4 industrial-grade 3D printer, designed to take manufacturing to new levels of efficiency and reliability. Factor 4 is an end-to-end 3D printing solution for light industrial applications
          • Heart
          • Thanks
          • Like
        • 7 replies
    ×
    ×
    • Create New...