Saturday, April 27, 2024
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 2538  / 2 Years ago, thu, january 20, 2022, 5:42:16

I am using Qt IDE in order to build my application so as to participate to the Ubuntu Showdown contest. In my application, I've done the following:



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));
}


So, basically I am trying to make a simple indicator entry, which, on click, it will hide the indicator and display the application. The indicator can be successfully hidden using the PASSIVE thingy over there, but, during the call data->show();, the application crashes.



Any help on what I am doing wrong would be appreciated! Also, please help me to correct this problem I'm facing (alternatively, I will migrate to the old and good tray icon (it works fine in 12.04, anyway) which I can handle very easily and efficiently)


More From » application-development

 Answers
5

You shouldn't use libappindicator for creating an Application Indicator in Qt programs. There's a better way!



If you have sni-qt installed that will automagically replace QSystemTrayIcon instances with the code for rendering that tray icon as a KDE Status Notifier Item, which the Application Indicator service will pick up and show in the Ubuntu menu bar.


[#37159] Thursday, January 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
istmasted

Total Points: 287
Total Questions: 130
Total Answers: 153

Location: Burkina Faso
Member since Thu, Dec 23, 2021
2 Years ago
istmasted questions
;