2013-02-12 30 views
2

所以我試圖在qt中設置這個窗口/ mainwindow /應用程序總是在底部(就像總是在底部窗口一樣)(所以rainmeter以某種方式將它與它們的小部件做在一起),但我甚至無法讓mac osx做這樣的事情。 我試過整個set qt C++ mainwindow總是在底部mac osx

this-> setWindowFlags(Qt :: WindowStaysOnBottomHint);

但沒有任何運氣。任何提示?示例代碼非常棒。

回答

5

有壞消息和好消息。壞消息是它根本沒有實現。

好消息是:由於Qt是開源的,你可以打開它並看看是否知道這一點。如果有錯誤,您可以提交修補程序。事情是這樣的,在QWidget::setWindowFlagsqwidget.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作爲練習留給讀者。 :-)

+0

Sucky。但是......在Qt的防守中,我會指出它確實會說「提示」。這是一種說法*「我希望這是真實的,如果它可以」* ... – HostileFork 2013-02-12 20:44:05

+0

我從來沒有傷心聽到這樣的'好'的消息。 – 2013-02-12 23:46:04