Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Swtiching from Java to C++... need help

Name: Anonymous 2006-12-18 12:18

Ok... I've taken two semesters of Java courses at Uni, and was thinking for marketability purposes, I better learn another, probably better, language. So I decided to try learning C++ since I heard they are pretty closely related, and I decided to use gtkmm for my GUI needs. However, I am running into difficulties, and I do not know if it is because I am a gigantic faggot, or what, I can't get this to work.

My idea was to try to write a very simple program that would basically allow me to add two numbers typed into two different text boxes, and output the answer. In my naiveté, I believe that once I overcome programming something that basic, that programming something more sophisticated should only then require that I can imagine it.

The problem is, the button that I try to add to the window does not appear to show up. I am wondering if I need to instantiate a container first, or what...

Below is a copy of my super simple source. Please ignore the inefficacy of including a whole one megabyte library for now, and help explain what I am doing wrong if you are able.

Thank you.

...
#include <gtkmm.h>

int main(int argc, char *argv[])
{
    Gtk::Main kit(argc, argv); //This creates the GTK main.

    Gtk::Window window; //This creates a window.
   
    Gtk::Button mButton;
    mButton.set_label("_Add"); //This creates a Button and labels it "Add" with an underline for A.

    window.add(mButton); //puts m_button into window.

    Gtk::Main::run(window); //This runs the window in the GTK main.
   
    return 0;
}
...

A picture of the resultant window:

http://img508.imageshack.us/img508/175/screenshotaddinged6.png

Name: Anonymous 2006-12-18 12:48

Thank you guys ever so much! The button does show up now... one more minor thing though, From the API and DOCs I'm reading, I understood it to mean that whatever character in a label for a button that is preceded by an underscore, should be underlined. This is not terribly important mind you, but the button literally had the label "_Add" as in the A was not underlined. In any case, thank you so much for the help. It feels weird knowing 40 percent of this stuff, and the other 60 makes no sense at all. :3

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List