Expand toolbar



  • Hello,

    I have a toolbar on the left of the screen.

    When I go over a toolbar button with the cursor, I want to expand 4 buttons as:
    picture
    http://www.cjoint.com/c/FLwuQArCebd

    It seems like a classic thing to do. Is there an automated method to do this ?

    Thank you very much,

    Alex


  • Lifetime Qt Champion

    Hi,

    Not that I'm aware of but one possibility could be to add a QMenu to your QToolButton and in there add a QWidgetAction on which you button a custom widget containing the buttons you want.

    Hope it helps



  • Thank you very much for the information. I think I found an easy way to do what I want to do. I will post my solution when its finished. However, there is a small problem with it.

    Here is a simplifified example. I have a rectangle with width 113. When I hover over the rectangle, I extend this rectangle width. When I exit the area, I reset the rectangle to its original width.

    This works. However, when I go on the design tab, I get a warning:
    Imperative code is not supported in the Qt Quick Designer. (M203) for the line (rectangle2.width=113 and rectangle2.width=113+107)

        Rectangle
        {
            id: rectangle2
            x: 430
            y: 296
            width: 113
            height: 105
            color: "#000000"
            MouseArea
            {
                anchors.fill: parent
                hoverEnabled: true
             
                onExited:
                {
                    rectangle4.visible=false
                    rectangle2.width=113
                }
                onEntered:
                {
                    rectangle4.visible=true
                    rectangle2.width=113+107
                }
            }
    

    Thank you very much for your help !

    Alex


  • Qt Champions 2016

    Hi
    instead of
    rectangle2.width=113+107
    try
    rectangle2.width=220



  • Thank you for your answer. I still have the same warning with this.
    I also had the warning with the other line (rectangle2.width=113).

    Thank you very much,

    Alex


  • Lifetime Qt Champion

    See here for that warning.



  • Ok thank you.
    I'm just not sure to understand.
    Can I ignore this warning ?
    Will my program won't work sometimes because of that ?

    Thank you so much,

    Alex


  • Lifetime Qt Champion

    AFAIK, That warning tells you that Qt Quick Designer can't handle that kind of stuff not that your code is inherently wrong.

    Again, AFAIK, The Qt Quick Designer was made to build your UI but not to handle logic in it which is what you added.



  • Thanks !


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.