Results 1 to 4 of 4

Thread: Combining Qt with GTK-only one problem!

  1. #1
    hakermania's Avatar
    hakermania is offline Τώρα ξέρεις τι γράφω εδώ!
    Join Date
    Aug 2009
    Location
    Greece
    Beans
    1,704
    Distro
    Ubuntu Development Release

    Question Combining Qt with GTK-only one problem!

    I am using this code:
    Code:
    g_signal_connect(showapp_option, "activate", G_CALLBACK(&MainWindow::show_app), appindicator);
    so as to connect my indicator menu item to the function show_app(), and it works just fine, irregardless the fact that I get the following warning:

    Code:
    warning: converting from 'void (MainWindow::*)()' to 'GCallback {aka void (*)()}' [-Wpmf-conversions]
    I don't understand the warning as I've never worked with the gtk libs before... Anyway, this isn't the real reason I'm posting here, but it is maybe related to it.

    The problem is that I cannot use 'this' (which stands for the MainWindow's call) from inside show_app() function, because the program crashes!

    Why I cannot use 'this' inside the function? And, more importantly, how do I make it work?
    Website

    Wallch (Wallpaper Changer): Sourceforge | Launchpad

  2. #2
    Join Date
    Mar 2006
    Beans
    837

    Re: Combining Qt with GTK-only one problem!

    As far as I can tell this is a problem relating to C not mixing well with C++.

    What type is "showapp_option"?

  3. #3
    hakermania's Avatar
    hakermania is offline Τώρα ξέρεις τι γράφω εδώ!
    Join Date
    Aug 2009
    Location
    Greece
    Beans
    1,704
    Distro
    Ubuntu Development Release

    Re: Combining Qt with GTK-only one problem!

    Quote Originally Posted by SledgeHammer_999 View Post
    As far as I can tell this is a problem relating to C not mixing well with C++.

    What type is "showapp_option"?
    After some inspection, that's my full updated code(which still doesn't work though):
    Code:
    void show_app(MainWindow *data)
    {
        //crashes here
        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));
    }
    I think that now things are more clear for you
    Last edited by hakermania; June 30th, 2012 at 09:19 AM.
    Website

    Wallch (Wallpaper Changer): Sourceforge | Launchpad

  4. #4
    hakermania's Avatar
    hakermania is offline Τώρα ξέρεις τι γράφω εδώ!
    Join Date
    Aug 2009
    Location
    Greece
    Beans
    1,704
    Distro
    Ubuntu Development Release

    Re: Combining Qt with GTK-only one problem!

    bump
    Website

    Wallch (Wallpaper Changer): Sourceforge | Launchpad

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •