QToolbar toolbutton layout
-
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.
-
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: 200toolBar: 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.