zoukankan      html  css  js  c++  java
  • [Qt] 通过socket将另一个程序的某个窗口调到最前端

    @ // THIS IS A HACK:
    // from QT documentation:
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // void QWidget::activateWindow ()
    // ...
    // On Windows, if you are calling this when the application is not currently
    // the active one then it will not make it the active window. It will change
    // the color of the taskbar entry to indicate that the window has changed in
    // some way. This is because Microsoft do not allow an application to
    // interrupt what the user is currently doing in another application.
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // This hack does not give the focus to the app but brings it to front so
    // the user sees it.
    ::SetWindowPos(effectiveWinId(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
    ::SetWindowPos(effectiveWinId(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
    // HACK END

    In linux i use this:

    if(!this->isActiveWindow())
    {   
    this->setWindowFlags((windowFlags() & Qt::WindowStaysOnTopHint));   this->setWindowFlags((windowFlags() & ~Qt::WindowStaysOnTopHint));   this->show();
    }

    I use this in windows, it works

        Qt::WindowFlags flags = windowFlags();
        this->setWindowFlags((flags | Qt::WindowStaysOnTopHint));
        this->show();
        this->setWindowFlags(flags);
        this->show();

    出处:https://forum.qt.io/topic/1939/activatewindow-does-not-send-window-to-front/11

  • 相关阅读:
    Linux-modules software
    Vim-Vundle-plugins-scripts
    Ubuntu-1404 GDB 调试C++报错
    Objdump-查看汇编指令
    Tornado-简介
    nginx-简介
    CentOS7 + linux kernel 3.10.94 compile 简记
    2020寒假学习笔记15------Spark基础实验
    2020寒假学习笔记14------Python基础语法学习(三)
    2020寒假学习笔记13------Python基础语法学习(二)
  • 原文地址:https://www.cnblogs.com/liujx2019/p/10696577.html
Copyright © 2011-2022 走看看