四月 14, 2011
Comments
原文链接:Morten Johan Sørvig - Mac Toolbars for Qt Quick
因为之前Jens写了一篇,我们正在进行自定义Qt Quick用于桌面的文章。在其中的一条留言中他也提到了我正在忙于一个有关Mac的项目。所以是时间发这篇文章了!
(译者注:这段视频放在YouTube,可能某些地区的朋友看不到)
运行中的工具栏:在Mac上已经习以为常,但自定义菜单对于Qt应用程序来说还算新事物。
这和现在的Qt中的解决方案有什么不同呢?首先,我们正在使用一个NSToolBar而不是QToolBar,这也就是说我们会自动获得正确的本地观感(包含所想要的自定义菜单)。其次,这个工具栏可以通过像任何其它QML项目一样这样创建:
MacToolBar {
MacToolButton {
text : "Button 1"
iconSource : "images/qtlogo.png"
toolTip : "This is button number 1"
onActivated : status.text = "Button1 Clicked"
}
MacToolButton { standardItem : MacToolButton.ShowColors }
MacToolButton { standardItem : MacToolButton.Space }
}
MacToolBars没有被绘制在QML的布景中,而是把一个NSToolBar附加到这个窗口中。
颜色板可以通过类似的方式访问:
MacColorPanel {
onColorChanged : { status.color = color; }
}
最后,如果您正从C++中使用Qt,这里还有一个基于QAction的界面:
QWidget *window = ...;
QtMacToolBar * macToolBar = new QtMacToolBar(window);
QAction * fooAction = macToolBar->addAction("FooButton");
QAction * barAction = macToolBar->addAction("BarButton");
macToolBar->showInWindow(window);
代码在qt-components/desktop的“mac”分支中的examples/MacToolbar.qml中。
Download the latest release here: www.qt.io/download
Qt 6.11 is now available, with new features and improvements for application developers and device creators.
Check out all our open positions here and follow us on Instagram to see what it's like to be #QtPeople.
最近注意到我们尚未发布 Qt Quick for Android 更新。Qt 6.11 即将发布,让我们先简单了解一下 Qt 6.9 和 Qt..
阅读文章