久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在沒有停靠欄圖標的 Mac OS X 中啟動 GUI 進程

Start a GUI process in Mac OS X without dock icon(在沒有停靠欄圖標的 Mac OS X 中啟動 GUI 進程)
本文介紹了在沒有停靠欄圖標的 Mac OS X 中啟動 GUI 進程的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個通常使用標準圖形界面運行的應用程序.但是,對于某些長時間運行的任務,它會生成以腳本模式"運行的同一應用程序的其他進程,我從父進程控制它.一切都很好,除了對于每個子進程,我都會得到另一個停靠欄圖標,該圖標會彈出一兩秒鐘然后消失.

I have an application that normally runs with a standard graphical interface. However, for certain long-running tasks, it spawns additional processes of the same application that run in a "script mode," where I am controlling it from the parent process. Everything works great, except that for each child process I get another dock icon that pops in for a second or two and then disappears.

有沒有辦法運行應用程序有時,而應用程序圖標不會顯示在 Dock 上?我無法編輯 info.plist 或任何東西,因為通常我想要停靠圖標.該選項必須能夠通過更改進程的屬性或通過命令行參數來設置.我可以完全控制應用程序的來源.它是用 C++ (Qt) 編寫的,但針對原生 Cocoa 庫的解決方案也不錯.

Is there a way to run an application sometimes without the application icon showing up on the dock? I can't edit the info.plist or anything because normally I want the dock icon. The option must be able to be set by changing a property on the process or via a command line parameter. I have full control over the source to the application. It is written in C++ (Qt), but solutions that target the native Cocoa library are fine.

如果我將此代碼放入單獨的應用程序中,則會導致大量重復,因此我寧愿保持原樣.我無法在后臺線程中運行長時間運行的任務,因為它們正在做必須在 GUI 線程中完成的事情.(在 Qt 中,您無法可靠地使用字體、像素圖或將 SVG 內容渲染到后臺線程的 QGraphicsScene 上.)

If I put this code into a separate application it would cause major duplication, so I'd rather keep it the way it is. I cannot run the long-running tasks in background threads because they are doing things that must be done in a GUI thread. (In Qt, you cannot reliably use fonts, pixmaps, or render SVG content onto a QGraphicsScene on background threads.)

有什么解決辦法嗎?

推薦答案

從 這里 得到啟發,您可以:

Motivated from here, you can do:

[NSApp setActivationPolicy: NSApplicationActivationPolicyAccessory];

[NSApp setActivationPolicy: NSApplicationActivationPolicyProhibited];

這應該隱藏停靠欄圖標.有關一些文檔,請參閱此處關于NSApplicationActivationPolicy.

This should hide the dock icon. See here for some documentation about NSApplicationActivationPolicy.

在 Python 中,隱藏停靠欄圖標的代碼是:

In Python, the code to hide the dock icon is:

# https://stackoverflow.com/a/9220857/133374
import AppKit
# https://developer.apple.com/library/mac/#documentation/AppKit/Reference/NSRunningApplication_Class/Reference/Reference.html
NSApplicationActivationPolicyRegular = 0
NSApplicationActivationPolicyAccessory = 1
NSApplicationActivationPolicyProhibited = 2
AppKit.NSApp.setActivationPolicy_(NSApplicationActivationPolicyProhibited)

另見相關問題如何隱藏 Dock 圖標".

如果你想避免一開始就彈出dock圖標,你可以這樣做:

If you want to avoid that the dock icon pops up at all right at the beginning, you can do that:

import AppKit
info = AppKit.NSBundle.mainBundle().infoDictionary()
info["LSBackgroundOnly"] = "1"

這篇關于在沒有停靠欄圖標的 Mac OS X 中啟動 GUI 進程的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 国精日本亚洲欧州国产中文久久 | 成人免费视频网站在线观看 | 久久国产精品-国产精品 | 久久伊人操 | 伊人狠狠操 | 欧美日韩国产一区二区 | 国产观看 | 中文字幕在线一区二区三区 | 97精品超碰一区二区三区 | 中文日韩在线视频 | 欧美精品一区二区在线观看 | 午夜资源| 8x国产精品视频一区二区 | 色资源站 | 电影91久久久 | 国产探花在线观看视频 | 日本黄色片免费在线观看 | 国产福利91精品一区二区三区 | 在线观看中文视频 | 伊人性伊人情综合网 | 久久国产精品久久国产精品 | 在线视频 亚洲 | 综合成人在线 | 日韩精品成人免费观看视频 | 日韩精品在线播放 | 久久久国产一区 | 亚洲天堂一区二区 | 成人免费毛片片v | 精品视频久久久 | 日本大香伊一区二区三区 | 日韩精品在线观看一区二区三区 | 日韩免费一区二区 | 国产精品亚洲综合 | 日韩欧美大片在线观看 | 成人不卡视频 | 九九久久精品视频 | 日本福利在线观看 | 欧美日韩视频网站 | 欧美一区二区三区在线看 | 午夜免费福利影院 | 国产精品久久久久久久久久久久久 |