widget application 区别?

liuguyue 2010-07-16 05:45:43

刚开始研究QT 一阵子。
看 reference 上 不理解 widget 和 application 的区别。
application里面的action 是什么意思呢? 和 widget 的 slot 有啥区别?

我是要做个导入数据绘图的小软件出来。
用Qt 主要是要看哪方面的内容呢?
...全文
309 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
tzcherish 2010-07-19
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 liuguyue 的回复:]
那 就是 看白皮书?!
[/Quote]

QT相关的书,至少要看基础篇,然后可以深入研究某一个部分~对QT一定要有个大致的了解。。。

liuguyue 2010-07-19
  • 打赏
  • 举报
回复
那 就是 看白皮书?!
tingsking18 2010-07-17
  • 打赏
  • 举报
回复
n applications many common commands can be invoked via menus, toolbar buttons, and keyboard shortcuts. Since the user expects each command to be performed in the same way, regardless of the user interface used, it is useful to represent each command as an action.

Actions can be added to menus and toolbars, and will automatically keep them in sync. For example, in a word processor, if the user presses a Bold toolbar button, the Bold menu item will automatically be checked.

Actions can be created as independent objects, but they may also be created during the construction of menus; the QMenu class contains convenience functions for creating actions suitable for use as menu items.

A QAction may contain an icon, menu text, a shortcut, status text, "What's This?" text, and a tooltip. Most of these can be set in the constructor. They can also be set independently with setIcon(), setText(), setIconText(), setShortcut(), setStatusTip(), setWhatsThis(), and setToolTip(). For menu items, it is possible to set an individual font with setFont().

Actions are added to widgets using QWidget::addAction() or QGraphicsWidget::addAction(). Note that an action must be added to a widget before it can be used; this is also true when the shortcut should be global (i.e., Qt::ApplicationShortcut as Qt::ShortcutContext).

Once a QAction has been created it should be added to the relevant menu and toolbar, then connected to the slot which will perform the action. For example:

openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
openAct->setShortcuts(QKeySequence::Open);
openAct->setStatusTip(tr("Open an existing file"));
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));

fileMenu->addAction(openAct);
fileToolBar->addAction(openAct);
We recommend that actions are created as children of the window they are used in. In most cases actions will be children of the application's main window.

See also QMenu, QToolBar, and Application Example.
benbenmajia 2010-07-17
  • 打赏
  • 举报
回复
还是建议通篇先了解一下
tzcherish 2010-07-17
  • 打赏
  • 举报
回复
先对QT有个大致了解~
信号-槽机制好好理解下。。。
lefttime 2010-07-16
  • 打赏
  • 举报
回复
[Quote=引用楼主 liuguyue 的回复:]
刚开始研究QT 一阵子。
看 reference 上 不理解 widget 和 application 的区别。
application里面的action 是什么意思呢? 和 widget 的 slot 有啥区别?

我是要做个导入数据绘图的小软件出来。
用Qt 主要是要看哪方面的内容呢?
[/Quote]
1. 在Qt中, widget是所有窗体的基类, 而application代表着你的整个应用程序; 你可以认为widget是组成application的基本元素, 但不一定要有; 至于application中的action....谁来解释下@@~``
2. slot的抽象意义是响应信号的处理函数, 它和widget的区别就是一个有形, 一个是无形~`
3. 你可以先看看Qt中的图形绘制篇~~`

16,173

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧