Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QToolbar toolbutton layout

    General and Desktop
    2
    3
    2492
    Loading More Posts
    • 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.
    • musimbate
      musimbate last edited by

      Hi all,
      I am trying to design a toolbar in a grid shape like "this":http://www.google.com/imgres?q=grid+toolbar&start=108&newwindow=1&biw=1440&bih=770&tbm=isch&tbnid=WcUgzmLiLn00lM:&imgrefurl=http://www.macprovideo.com/hub/reaper/deck-the-halls-with-reaper&docid=CanQCrcBK_1EXM&imgurl=http://macprovid.vo.llnwd.net/o43/hub/media/1080/7845/10_Grid_and_Snap_Enabled.jpg&w=561&h=237&ei=NfSfUbjiIaHuigLJioGACw&zoom=1&ved=1t:3588,r:8,s:100,i:28&iact=rc&dur=308&page=6&tbnh=143&tbnw=340&ndsp=22&tx=235&ty=76 .I have created a QGridLayout and stuffed my actions in but I am getting strange results. I also want to have some kind of rounded border on each button group.QToolbar seems not to be flexible with layouts.Is there any standard way of achieving this?

      Thanks.

      Why join the navy if you can be a pirate?-Steve Jobs

      1 Reply Last reply Reply Quote 0
      • A
        Alek Śmierciak last edited by

        If it is an option, you can take a look at "QtQuickControls":http://doc-snapshot.qt-project.org/qt5-stable/qtquickcontrols/qtquickcontrols-index.html made available in Qt5.1, in particular, at the "ToolBar":http://doc-snapshot.qt-project.org/qt5-stable/qtquickcontrols/qml-qtquick-controls1-toolbar.html element.
        As the ToolBar element does not specify inner layout, it needs to be added explicitly, which is actually a benefit in your case. You can specify a Grid inside and lay the buttons to your liking.

        @ApplicationWindow {
        width: 300
        height: 200

        toolBar: ToolBar {
            Grid {
                ToolButton {
                    id: button1
                    text: "1st button"
                }
                ToolButton {
                    id: button2
                    text: "2nd button"
                }
                ToolButton {
                    id: button3
                    text: "3rd button"
                }
                ToolButton {
                    id: button4
                    text: "4th button"
                }
                ToolButton {
                    id: button5
                    text: "5th button"
                }
                ToolButton {
                    id: button6
                    text: "6th button"
                }
                ToolButton {
                    id: button7
                    text: "7th button"
                }
            }
        }
        

        }
        @

        Creating and styling a button group will be a matter of styling the Grid (or Row or Column, whichever you use). You might also find "Action":http://doc-snapshot.qt-project.org/qt5-stable/qtquickcontrols/qml-qtquick-controls1-action.html element useful, especially when adding keyboard shortcuts or menu bar for commands already in the button grid.

        1 Reply Last reply Reply Quote 0
        • musimbate
          musimbate last edited by

          Thanks Alek Śmierciak for your reply.The application I am working on is done in Qt 4 ,unfortunately this is not an option for me.Guess I ll keep looking for a possible solution.
          Cheers!

          Why join the navy if you can be a pirate?-Steve Jobs

          1 Reply Last reply Reply Quote 0
          • First post
            Last post