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,

Note: This all function will work only when toolbar is placed in QMainWindow.
  • 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

<?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

--nayan_trivedi


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!

最新文章

  1. Norflash控制器的Verilog建模之二(仿真)
  2. js 函数声明方式以及javascript的历史
  3. 百度面试题:从输入url到显示网页,后台发生了什么?
  4. js之script属性async与defer
  5. C#开发SQLServer的Geometry和Geography存储
  6. ssdt_hook NtOpenProcess
  7. 工艺成型及仿真、铸造工艺及仿真ProCAST软件入门认识介绍
  8. 关于Spring的69个面试问答——终极列表
  9. WPF---Effect效果
  10. Kali Linux虚拟机安装完整安装过程及简单配置(视频)
  11. IP地址转为二进制,去掉0b补齐八位拼接,再转为十进制
  12. php中的echo 与print 、var_dump 的区别
  13. JavaScript原型详解
  14. hibernate11--Criteria查询
  15. JavaScript倒计时实现
  16. oracle-gi安装
  17. zip命令详解
  18. 咏南中间件增加WEBSOCKET支持
  19. test20190308
  20. 无偏方差为什么除以n-1

热门文章

  1. 《从零开始学Swift》学习笔记(Day 37)——默认构造函数
  2. 合并子目录(hash)
  3. 关于angularjs的orderby排序
  4. 第一次打开Pycharm如何操作?
  5. Python菜鸟之路:通过案例学习JQuery
  6. [NOIP2018PJ]对称二叉树
  7. DMR技术白皮书
  8. attention机制七搞八搞
  9. 高斯过程(GP)
  10. C语言运算符优先级误解