久久久久久久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 ()?環形?)
主站蜘蛛池模板: 激情福利视频 | 99视频在线免费观看 | 成人在线精品视频 | 国产精品成人一区二区三区 | 亚洲精品久久久一区二区三区 | 国产亚洲精品精品国产亚洲综合 | 久久久久久久91 | 国产精品久久国产精品 | 91精品中文字幕一区二区三区 | 欧美xxxx性xxxxx高清 | 岛国视频 | 日日夜夜天天 | 国产一区二区麻豆 | 一级a毛片 | 91免费在线 | 亚洲精品99 | 精品久久久一区 | 精品小视频 | 亚洲精品电影 | 亚洲精品无 | a级在线免费观看 | 国产欧美一区二区精品久导航 | 国产伦精品一区二区三毛 | 九九热最新视频 | 欧美一区久久 | 超碰欧美 | 国产高清性xxxxxxxx | 成人欧美在线 | 日日夜夜精品视频 | 亚洲成人一区二区 | 91精品国产欧美一区二区成人 | 欧美天堂在线观看 | 国产欧美一区二区三区在线看 | 中文字幕日韩一区二区 | 992人人草| 日韩国产高清在线观看 | 久久99精品视频 | 天天天插 | 久久久久久免费毛片精品 | 在线亚洲欧美 | 91天堂网|