如何给Meego应用添加通用导航栏?

发布于 2024-10-18 10:12:03 字数 754 浏览 3 评论 0原文

使用 Meego Touch Framework 时,标准 MApplicationWindow 已附加通用导航栏(带有切换器、菜单和关闭按钮)。

例如,以下代码:

#include <MApplication>
#include <MApplicationWindow>

int main(int argc, char *argv[]){
    MApplication app(argc, argv);
    MApplicationWindow w;
    w.show();
    return app.exec();
}

创建一个带有菜单栏的空白窗口,其外观为 与此类似(例如顶部的切换器按钮、菜单和关闭按钮)。

但是,由于 docs 不鼓励使用触摸框架,我想避免使用它,那么我如何仅使用 标准 API?

When using the Meego Touch Framework, the standard MApplicationWindow has the common navigation bar (with the switcher, menu and close buttons) already attached.

For example, the following code:

#include <MApplication>
#include <MApplicationWindow>

int main(int argc, char *argv[]){
    MApplication app(argc, argv);
    MApplicationWindow w;
    w.show();
    return app.exec();
}

Creates a blank window with a menu bar that looks similar to this (eg. the switcher button, menu and close button along the top).

However, since the the docs discourage the use of the Touch Framework I want to avoid using it, so how would I create a similar looking window using only the standard API?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

满意归宿 2024-10-25 10:12:03

我将如何实现这一点,可能是一个固定高度、可变宽度的 QHBoxLayout,并为需要它的索引提供拉伸因子。然后我将使用 QPushButton 和 QCombobBox 作为小部件,并使用自定义样式表和图标完成它们。然后,我将它们包装在一个整洁的小自定义小部件中,我可以在我的主视图类中重用它。

主视图应该是一个窗口类,它将导航栏小部件放在 QVBoxLayout 之上,并将实际内容放在它下面。底部索引将具有拉伸因子,以便上部索引始终位于顶部。

我不太记得 Meego 手机 UX 应该如何运作,但这就是我创建一个类似的导航栏的方式。

How I would implement this, would probably be a fixed height, variable width QHBoxLayout with a stretch factor for those indices that need it. Then I would just use QPushButton and QCombobBox for the widgets and finish them off with a custom stylesheet and icons. I would then wrap these inside a neat little custom widget that I could reuse in my main view class.

The main view should be a window class that would hold the navigation bar widget on top of a QVBoxLayout, and the actual content below it. The bottom index would have a stretch factor to it, so that the upper index would always be at the top.

I don't quite remember how the Meego handset UX should act like, but that's how I would create a similar looking navigation bar.

烂人 2024-10-25 10:12:03

我只想使用 QMainWindow 类,因为该类已经有菜单、工具栏、状态栏。
但是,您应该自己处理方向切换(我看到纵向模式下的工具栏位于底部,而横向模式下则位于顶部)。
这可以通过设置正确的 Qt::ToolbarArea 值来完成。

按钮和窗口本身的样式可以使用 Qt 样式表进行设置。

I would just go with the QMainWindow class, as this class already has menus, toolbars, statusbar aso.
You should however take care of the orientation switching yourself (I see that the toolbar in portrait mode is at the bottom, while in landscape mode it is on the top).
This could be accomplished by setting the right Qt::ToolbarArea value.

The style of the buttons and the window itself, can be set using a Qt stylesheet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文