简体   繁体   English

Qt如何添加到Windows标题栏?

[英]Qt how do you add to the Windows Title bar?

I have the follow example (from GlassWire) and I know it was built using Qt but I can't seem to figure out how to put stuff in the "Windows Title Bar" the semi translucent part of the Window Frame. 我有一个以下示例(来自GlassWire),并且我知道它是使用Qt构建的,但是我似乎无法弄清楚如何将东西放入“ Windows标题栏”窗口框架的半透明部分。 Like in this example, we have a QPushButton GlassWire button and then we have 4 tabs, all in the normal Windows frame. 像在此示例中一样,我们有一个QPushButton GlassWire按钮,然后有4个选项卡,所有这些选项卡都在常规Windows框架中。

I can't seem to figure out how to do something like that. 我似乎不知道该怎么做。 Any ideas on how I could, for example, add a QPushButton in the bar? 关于如何进行操作的任何想法,例如,在栏中添加QPushButton?

I would do something like http://msdn.microsoft.com/en-us/library/windows/desktop/bb688195(v=vs.85).aspx if I was doing this outside of Qt. 如果我在Qt之外执行此操作,则可能会执行http://msdn.microsoft.com/zh-CN/library/windows/desktop/bb688195(v=vs.85).aspx之类的操作。

例

I managed to get it done by doing something like this: 我设法通过做这样的事情来做到这一点:

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWin>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

#ifdef Q_OS_WIN
    this->setAttribute(Qt::WA_TranslucentBackground);
    QtWin::enableBlurBehindWindow(this);
    QtWin::extendFrameIntoClientArea(this, -1, -1, -1, -1);
#endif
}

MainWindow::~MainWindow()
{
    delete ui;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM