[英]GTK app: How do I create a working indicator with Qt/C++?
我已經在2個論壇中嘗試過,但是到目前為止我還沒有運氣。
因此,我正在使用Qt IDE來構建我的應用程序,以便參加Ubuntu Showdown競賽。 在我的應用程序中,我完成了以下操作:
void show_app(MainWindow *data)
{
//this works fine:
app_indicator_set_status(appindicator, APP_INDICATOR_STATUS_PASSIVE);
//this crashes the application:
data->show();
}
void MainWindow::make_indicator()
{
if(appindicator){
//appindicator has already been created
return;
}
appindicator = app_indicator_new("Format Junkie Indicator", "formatjunkie", APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
GtkWidget* showapp_option;
GtkWidget* indicatormenu = gtk_menu_new();
GtkWidget* item = gtk_menu_item_new_with_label("Format Junkie main menu");
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), indicatormenu);
showapp_option = gtk_menu_item_new_with_label("Show App!");
g_signal_connect(showapp_option, "activate", G_CALLBACK(show_app), this);
gtk_menu_shell_append(GTK_MENU_SHELL(indicatormenu), showapp_option);
gtk_widget_show_all(indicatormenu);
app_indicator_set_status(appindicator, APP_INDICATOR_STATUS_ACTIVE);
app_indicator_set_attention_icon(appindicator, "dialog-warning");
app_indicator_set_menu(appindicator, GTK_MENU (indicatormenu));
}
因此,基本上,我正在嘗試創建一個簡單的指標條目,單擊該條目將隱藏指標並顯示應用程序。 使用該處的PASSIVE工具可以成功隱藏該指示器,但是在調用data-> show();期間,應用程序崩潰。
任何對我做錯事的幫助將不勝感激! 另外,請幫助我糾正我面臨的這個問題(或者,我將遷移到舊的且良好的任務欄圖標(無論如何,它在Ubuntu 12.04中都可以正常工作),我可以非常輕松有效地處理它)
activate
信號的回調必須具有以下類型:
void callback(GtkMenuItem *, gpointer)
所以show_app
應該這樣定義
void show_app(GtkMenuItem *showapp_option, MainWindow *data)
那應該解決您的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.