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

  • Home
  • SEARCH
  • 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 1009539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:56:41+00:00 2026-05-16T08:56:41+00:00

I am writing a GTK+ application in C (though the principle here is widely

  • 0

I am writing a GTK+ application in C (though the principle here is widely applicable) which contains a GtkComboBox. The GtkComboBox is part of a larger structure returned by another function and packed into the main window.

I don’t see how I can get the value of what is selected in the GtkComboBox other than by setting a global variable from its callback function. Or is there still some way of referring to the GtkComboBox later in the program, outside of the function which declared it?

Or should I not be declaring it inside a function (other than main( )) in the first place?

  • 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-05-16T08:56:42+00:00Added an answer on May 16, 2026 at 8:56 am

    If the function that declares a stack variable in C has returned, that variable is no more. If you need GtkComboBox (or other object) to persist, you have a few options:

    • Use malloc to allocate space for it and pass around a pointer (which must be freed when you no longer need it).
    • Use a global variable
    • Don’t use callbacks and declare it in an outer function and pass it around.

    I would probably go with the malloc/pass around a pointer approach, but can’t be sure without more knowledge of your situation.

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

Sidebar

Related Questions

I've got a gtk file chooser button on my application I am writing in
I'm writing a game in C using the Gtk libraries, in which the player
I'm writing by hand an application that use Gtk+ . I'm using a GtkGrid
I am building my first GTK application. I am writing my app in Mono
I'm writing an application with a GUI frontend (GTK) and an SQLite backend. When
I'm writing an application [a Pidgin plugin, actually], which inserts an image embedded into
I'm writing a GTK+ application. At the end of the program's running, it opens
I am writing a simple application and am using glade (gtk) for the UI.
I'm writing a Gtk+ menu bar following the instruction here . When packing the
I am writing application in C# using GTK# GUI framework to make it cross-platform.

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.