【发布时间】:2013-01-28 02:02:50
【问题描述】:
所以我试图在 qt 中将此窗口/主窗口/应用程序设置为始终位于底部(就像始终位于底部窗口一样)(因此 Rainmeter 以某种方式使用他们的小部件执行此操作),但我什至无法让 mac osx做这样的事情。 我已经尝试了整个
this->setWindowFlags(Qt::WindowStaysOnBottomHint);
但没有任何运气。有什么提示吗?示例代码很棒。
【问题讨论】:
所以我试图在 qt 中将此窗口/主窗口/应用程序设置为始终位于底部(就像始终位于底部窗口一样)(因此 Rainmeter 以某种方式使用他们的小部件执行此操作),但我什至无法让 mac osx做这样的事情。 我已经尝试了整个
this->setWindowFlags(Qt::WindowStaysOnBottomHint);
但没有任何运气。有什么提示吗?示例代码很棒。
【问题讨论】:
有坏消息和好消息。坏消息是它根本没有实施。
好消息是:由于 Qt 是开源的,你可以打开它看看就知道了。如果有错误,您可以提交修复。这是交易,在QWidget::setWindowFlags 的通用代码中
qwidget.cpp:9144你有这个:
void QWidget::setWindowFlags(Qt::WindowFlags flags)
{
if (data->window_flags == flags)
return;
Q_D(QWidget);
if ((data->window_flags | flags) & Qt::Window) {
// the old type was a window and/or the new type is a window
QPoint oldPos = pos();
bool visible = isVisible();
setParent(parentWidget(), flags);
// if both types are windows or neither of them are, we restore
// the old position
if (!((data->window_flags ^ flags) & Qt::Window)
&& (visible || testAttribute(Qt::WA_Moved))) {
move(oldPos);
}
// for backward-compatibility we change Qt::WA_QuitOnClose attribute value only when the window was recreated.
d->adjustQuitOnCloseAttribute();
} else {
data->window_flags = flags;
}
}
所以本质上它只是设置window_flags。 QWidget的mac行为在qwidget_mac.mm。
您将在该文件中找不到对Qt::WindowStaysOnBottomHint 的引用。 (虽然你会找到 Qt::WindowStaysOnTopHint...)
我会停止说“除非你修补Qt,否则不可能进入Qt”。
修补qwidget_mac.mm 留给读者作为练习。 :-)
【讨论】: