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 ...
随机推荐
- 注册Asp4.0到iis
- zend studio,操作记录
1.代码字体大小 打开Window->Preferences->General->Apperance-Colors and fonts->Structured Text Edi ...
- MogoDB 分片键
MongoDB 根据分片键分割 collection 中的文档,然后分配到分片集群的成员中. 分片键可以是一个存在于每个文件中的索引字段或者复合索引字段. MongoDB 使用不同范围的分片键值来分割 ...
- coursera 《现代操作系统》 -- 第八周 存储模型(2)
名词解释 页面: 页面大小: 页表: 页表项: 以上名词解释见: coursera <现代操作系统> -- 第七周 存储模型(1) 页表项大小: 问:以上是怎么计算出来的? 32位指什么? ...
- python面试题(七)
1 什么是局域网.广域网.城域网? ①局域网LAN(Local Area Network):一般指覆盖范围在10公里以内,一座楼房或一个单位内部的网络.由于传输距离直接影响传输速度,因此,局域网内的通 ...
- selenium 下载文件设置下载路径
Chrome 文件下载 Chrome浏览器类似,设置其options: download.default_directory:设置下载路径 profile.default_content_settin ...
- elementUI增加同级下级
<template> <div> <el-row> <el-col :span="4"> <el-button v-on:cl ...
- 什么是 XML Schema(转)
什么是 XML Schema? XML Schema 的作用是定义 XML 文档的合法构建模块,类似 DTD. XML Schema 的作用: 定义可出现在文档中的元素 定义可出现在文档中的属性 定义 ...
- Android:日常学习笔记(8)———探究UI开发(2)
Android:日常学习笔记(8)———探究UI开发(2) 对话框 说明: 对话框是提示用户作出决定或输入额外信息的小窗口. 对话框不会填充屏幕,通常用于需要用户采取行动才能继续执行的模式事件. 提示 ...
- java多线程笔记
一,线程的状态 1,新建状态:新创建了一个线程对象 2,就绪状态:线程创建对象后,线程调用star()的方法,等待获取CPU的使用权. 3,运行状态:获取了cpu的使用权,执行程序代码 4,阻塞状态: ...