How to use QToolBar and QToolButton in Qt
http://developer.nokia.com/Community/Wiki/How_to_use_QToolBar_and_QToolButton_in_Qt
How to use QToolBar and QToolButton in Qt
Introduction
This is a small code snippet which shows the use of the toolbar and tool button inQt.
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.
Code Snippet
#include <QApplication>
#include <QToolButton>
#include <QToolBar>
#include <QWidget>
#include <QVBoxLayout>
#include <QIcon>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *win = new QWidget;
QToolBar *tool = new QToolBar;
tool->setGeometry(0,0,200,20);
QVBoxLayout *layout = new QVBoxLayout;
QToolButton *button = new QToolButton;
button->setGeometry(0,0,10,20);
button->setIcon(QIcon("c://openbutton.png"));
QToolButton *button1 = new QToolButton;
button1->setIcon(QIcon("c://savebutton.png"));
QToolButton *button2 = new QToolButton;
button2->setIcon(QIcon("c://exitbutton.png"));
tool->addWidget(button);
tool->addSeparator();
tool->addWidget(button1);
tool->addSeparator();
tool->addWidget(button2);
layout->addWidget(tool);
win->setLayout(layout);
win->showMaximized();
return app.exec();
}
Screenshot

Making the toolbar movable
The toolbar can be made movable by using the following functions,

- This function is used to move toolbar in QMainWindow.
toolbar->setMovable(1);
- This is used to enable drag and drop toolbar.
toolbar->setFloatable(1);
- This is used to know were toolbar is to be place in QMainWindow.
toolbar->setAllowedAreas(Qt::AllToolBarAreas);
More information
- More about QToolBar
- More about QToolButton
<?NOINDEX-START?>
Comments
This article shows the use of QtoolBar and QtoolButton.This article is one of the basic article of QT.
Tool button is a special button that provides quick-access to specific commands or options. As opposed to a normal command button, a tool button usually doesn't show a text label, but shows an icon instead.
The QToolBar class provides a movable panel that contains a set of controls.When a toolbar is resized in such a way that it is too small to show all the items it contains, an extension button will appear as the last item in the
toolbar. Pressing the extension button will pop up a menu containing the items that does not currently fit in the toolbar
Article shows the various functions of QtoolBar and QtoolButton. Introduction of the article explain every thing about the intact article. And in the end image partial with great hand.(things)
$ [--fasttrack 18:59, 12
September 2009 (UTC)]
QToolbar isn't supposed to be properly supported on Symbian. How does this look on a real device? Do you need to explicitly set geometry?
hamishwillee 22:14, 10 January 2011 (UTC)
NightOwl - Add QToolBar to "SoftKey Bar" / "Control Pane" / "Command Button Area"
Hello,
I have been searching everywhere on the web in hopes of finding a code example that shows how to add a QToolbar to the "SoftKey Bar" / "Control Pane" / "Command Button Area" (the default bar at the bottom of the screen). Would
someone please post an example of how to do this?
Thank you!
How to use QToolBar and QToolButton in Qt的更多相关文章
- qt 5.2.1类和模块的关系图
QT│ ├─ActiveQt│ │ ActiveQt│ │ ActiveQtDepends│ │ ActiveQtVersion│ │ QAxAggregated│ │ QAxB ...
- QToolButton设置icon的大小
项目中用到了QToolButton上使用图片. 如果在maindow中直接使用QToolButton,如: btnSimulate = new QToolButton; btnSimulate-> ...
- 用Qt写软件系列五:一个安全防护软件的制作(2)
引言 在上一篇中讲述了主窗体的创建和设计.主窗体的无边框效果.阴影效果.拖动事件处理.窗体美化等工作在前面的博客中早就涉及,因此上篇博文中并未花费过多笔墨.这一篇继续讲述工具箱(Tool Button ...
- Qt Widgets——主窗口及其主要组成部分
Main Window and Related Classes QAction 动作类,用于当做一个菜单项或工具项插入菜单或工具栏 QActionGroup 动作组,用于管理多个动作,设置它们之间的互 ...
- Qt与PyQT中设置ToolBar在AllowedArea的显示
因为个人对传统的软件GUI界面不是太喜欢,最近又在学习Qt和PyQt5,所以就有了设置ToolBar在窗口的不同地方的想法,经过浪里淘沙,最终在Qt官网里找到了,原来再添加toolBar的时候是由设置 ...
- API Design Principles -- QT Project
[the original link] One of Qt’s most reputed merits is its consistent, easy-to-learn, powerfulAPI. T ...
- qt_文本编辑器实现_附带详细注释和源码下载
源码下载: 链接: http://pan.baidu.com/s/1c21EVRy 密码: qub8 实现主要的功能有:新建,打开,保存,另存为,查找(查找的时候需要先将光标放到最下面位置才能查全,不 ...
- QT_文本编辑器_源码下载
源码下载: 链接: http://pan.baidu.com/s/1c21EVRy 密码: qub8 实现主要的功能有:新建,打开,保存,另存为,查找(查找的时候需要先将光标放到最下面位置才能查全,不 ...
- setStyleSheet 一些QSS设置的集合
setStyleSheet 设置的一些集合,一部分源码和截图来自 http://blog.sina.com.cn/s/articlelist_2801495241_0_1.html 1. 设置QLab ...
随机推荐
- keras常用的网络层
一.常用层 常用层对应于core模块,core内部定义了一系列常用的网络层,包括全连接.激活层等. 1.Dense层 Dense层:全连接层. keras.layers.core.Dense(outp ...
- python学习【第七篇】python文件操作
一.文件操作过程 1. 打开文件,得到文件句柄并赋值给一个变量2. 通过句柄对文件进行操作3. 关闭文件 # 1.打开文件,得到文件句柄 f_handle = open('aa.txt', 'r', ...
- tomcat 配置自签名ssl证书
背景:据说17年苹果app必须走https协议与后台交互了,网上各种搜索最后还是发现有2篇写的比较全面,折腾后总结出2种实现方式.在这里记录,方便有共同需求的同学们参考 本文只介绍生成自签名ssl证书 ...
- 查看java进程的所有信息
查看java 进程下的所有信息 ll /proc/pid/fd ru:ll /proc/24047/fd
- git commit -a -m "DM 1、获取aliOssSTS值,计算签名,实现视频PUT/POST2种上传方式上传;"
git commit -a -m "DM 1.获取aliOssSTS值,计算签名,实现视频PUT/POST2种上传方式上传:" 微信小程序的视频上传
- nosql_action
ps -aux 查当前端口占用 connecting to: test > show dbs local .078125GB testphp .203125GB > use testph ...
- iOS 多线程之 NSThread的基本使用
一个NSThread对象就代表一条线程 下面是NSThread开启线程的方法 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEv ...
- Ensemble learning(集成学习)
定义 集成学习是一种机器学习范式,其中多个学习器被训练来解决相同的问题. 这与试图从训练数据中学习一个假设的普通机器学习方法相反,集成方法尝试构造一组假设并将它们结合使用. 一个集合包含一些通常被称为 ...
- java bio 之聊天室
最近在复习java io相关知识 ,发现很多细节之前没学习到位,原理也没吃透,只能感叹本人愚钝. 复习到bio,顺手写了个简单的聊天室功能,并和大家分享下. 服务端: package io.QQ聊天室 ...
- "深入理解C语言" 指针
本文对coolshell中的"深入理解C语言"这篇文章中提到的指针问题, 进行简要的分析. #include <stdio.h> int main(void){ ]; ...