在底部mac osx上设置qt c ++ mainwindow

Ros*_*oss 2 c++ macos qt window

所以,我想设置QT这个窗口/主窗口/应用程序始终在底部(像往常一样底窗)(这样的Rainmeter不知何故这是否与他们的小部件),但我甚至不能Mac OSX上做这种事情.我试过了整个

这 - > setWindowFlags(QT :: WindowStaysOnBottomHint);

但没有任何运气.任何提示?示例代码很棒.

小智 5

得到了坏消息和好消息.坏消息是它根本没有实现.

好消息是:由于Qt是开源的,你可以打开它并看一看就知道了.如果有错误,您可以提交修复程序.这是交易,在qwidget.cpp的通用代码QWidget::setWindowFlags: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;
    }
}
Run Code Online (Sandbox Code Playgroud)

所以基本上它只是设置window_flags.QWidget的mac行为在qwidget_mac.mm中.

你将Qt::WindowStaysOnBottomHint在该文件中找不到任何引用.(你会发现Qt::WindowStaysOnTopHint......)

我会停止说"除非你要么补Qt,否则不要去Qt",否则"不可能".

补丁qwidget_mac.mm留给读者作为练习.:-)