如何更改 Qt::Drawer 在 Mac 上打开的一侧?

发布于 2024-10-21 21:10:49 字数 218 浏览 1 评论 0原文

问候!

我有一个 QDialog myDialog; 并希望使用 QWidget myDrawer( &myDialog, Qt::Drawer ) 向其附加附加信息。这工作得很好,只是抽屉总是将自己附加到 myDialog 的左侧。我需要它在右侧。我不知道该怎么做。

任何提示和想法将不胜感激! 谢谢,并致以最诚挚的问候, 罗宾

Greetings!

I have a QDialog myDialog; and want to attach additional information to it using QWidget myDrawer( &myDialog, Qt::Drawer ). This works fine, except that the drawer always attaches itself to the left side of myDialog. I need it on the right side. And I have no clue how to do that.

Any hints and ideas would be greatly appreciated!
Thanks, and best regards,
Robin

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

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

发布评论

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

评论(2

客…行舟 2024-10-28 21:10:49

这通常由操作系统完成。尝试将窗口移至靠近屏幕左边缘并打开抽屉 - 它现在应该在右侧打开。

一般来说,尽量避免使用抽屉,因为它们似乎不受欢迎,并且不再是当今预期的“外观和感觉”的一部分。


更新:

抱歉 - 正确,它们仍然在人类交互中指南,但大多数开发人员不再使用它们。从几个论坛和 IRC 频道的讨论来看,它们似乎感觉“不自然”,因为它们不是“窗口”的一部分。

回到你的问题;我怀疑你能控制抽屉从 Qt 滑出的一侧。另外,根据您使用的是 Cocoa- 还是 Carbon-Qt,它可能会有所不同。至少我在 Qt 文档中找不到任何相关内容。

This is normally done by the OS. Try moving the window close to the left edge of your screen and open the drawer - it should now open on the right-hand side.

Generally, try to avoid using drawers, as they are seemingly being frowned upon and not part of the expected "look and feel" these days anymore.


Update:

Sorry - Correct, they are still in the Human Interace Guidelines, but most developers don't use them anymore. From discussions on several boards and IRC channels it seems that they feel "unnatural" as they are not part of the "window".

To get back to your question; I doubt you can control the side the drawer slides out from Qt. Plus it might make a difference depending on if you are using Cocoa- or Carbon-Qt. At least I couldn't find anything regarding that in the Qt documentation.

眼泪都笑了 2024-10-28 21:10:49

demos\mainwindow项目中,mainwindow.cpp中有几行(第311-314行):

#ifndef Q_WS_MAC
    { "Black", 0, Qt::LeftDockWidgetArea },
#else
    { "Black", Qt::Drawer, Qt::LeftDockWidgetArea }

我现在无法访问OS X,但是我记得我通过上述项目学会了改变抽屉的侧面。所以你可以在 OS X 中尝试这个项目。

这是可能的:
右边
bottom

但是您必须使用 QDockWidget 作为 Qt::Drawer 小部件;
以下代码来自 QMainWindow 类:

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QDockWidget *drawdock = new QDockWidget(this,Qt::Drawer);
    this->addDockWidget(Qt::RightDockWidgetArea,drawdock);
}

要在运行时更改抽屉的一侧:

QMainWindow *mainWindow = qobject_cast<QMainWindow *>(this);
mainWindow->addDockWidget(Qt::BottomDockWidgetArea,drawdock);

这些区域可以是 DockWidgetAreas

In the demos\mainwindow project, there are a few lines (lines 311-314) in mainwindow.cpp:

#ifndef Q_WS_MAC
    { "Black", 0, Qt::LeftDockWidgetArea },
#else
    { "Black", Qt::Drawer, Qt::LeftDockWidgetArea }

I don't have access to OS X right now, but I remember I learnt to change the side of the drawer by the above-mentioned project. So you could playaround with this project in OS X.

this is possible:
on right
bottom

but you will have to use QDockWidget as the Qt::Drawer widget;
the following code is from a QMainWindow class:

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QDockWidget *drawdock = new QDockWidget(this,Qt::Drawer);
    this->addDockWidget(Qt::RightDockWidgetArea,drawdock);
}

To change the side of the drawer during runtime:

QMainWindow *mainWindow = qobject_cast<QMainWindow *>(this);
mainWindow->addDockWidget(Qt::BottomDockWidgetArea,drawdock);

The areas could be any one of the DockWidgetAreas

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