Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7846611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:38:24+00:00 2026-06-02T17:38:24+00:00

Recently I’ve started a C++ project in order to skill myself with GTK functions.

  • 0

Recently I’ve started a C++ project in order to skill myself with GTK functions. I’ve used C++ approach ’cause i always programmed in java, so it seems to me much familiar.

Now, GTK libraries are written in C code, so i achieved some mix between classes and C codestyle. One of my issues is that GTK events works with callback functions. To encapsulate those event in classes I made use of static methods.

The big deal is that static methods and static variables are not visible from inside the class, plus I’ve written some other static functions, declared only in the .cpp file of the class, called from inside the callbacks but completely separated from the class.

It seems to me this approach is a bit clumsy, so I wonder is there any best approach in order to handle those callbacks in classes and allow them to interact with class methods and structures in an elegant way?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:38:27+00:00Added an answer on June 2, 2026 at 5:38 pm

    Yes, you need to pass the state (For instance you this pointer, or a pointer to some slot/functor) in the user_data parameter. Otherwise, you will never have a class instance with which to call your member method.

    This is what gtkmm does. For instance, Gtk::Container::foreach() uses a static (non member) function, passing a provided sigc::slot to it:
    http://git.gnome.org/browse/gtkmm/tree/gtk/src/container.ccg#n166

    The code for signals (what you call events in your question) is similar, but slightly more complicated – you can see that in the generated .cc code in gtkmm.

    But, I also think that you should just use gtkmm. This is just one of several problems that you would otherwise end up (not) solving yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

recently I started a small Django project that I developed on a local machine
Recently I just got assigned a project to develop a web application/site that uses
recently I started using storyboard and I've the following situation: I want to set
Recently two users of our software from the same company started experiencing random closures
Recently downloaded some code for a minor open-source project related to a small webgame
Recently I've been doing quite the project mostly working with the DateTime class. Now,..
Recently, I added a setup project to my application. In the setup project, I
Recently I started reading (just a bit) the current draft for the future C++11
Recently in a project, I had a multiprocessing Process that crashed. A child process
Recently I have migrated my project from SQLServer 2000 to MySQL 5.2 using MySQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.