Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
How to use QToolBar and QToolButton in Qt
This is a small code snippet which shows the use of the toolbar and tool button in Qt. With use of this code snippet one can easily create a small toolbar and adds buttons to it. Here all three buttons are set for same function that is to quit from application.
int main(int argc, char *argv)
QApplication app(argc, argv);
QWidget *win = new QWidget;
QToolBar *tool = new QToolBar;
QVBoxLayout *layout = new QVBoxLayout;
QToolButton *button = new QToolButton;
QToolButton *button1 = new QToolButton;
QToolButton *button2 = new QToolButton;
Making the toolbar movable
The toolbar can be made movable by using the following functions,
- This function is used to move toolbar in QMainWindow.
- This is used to enable drag and drop toolbar.
- This is used to know were toolbar is to be place in QMainWindow.