Re: Beginner Question: Changing the Text of a Button



I'm on my phone, but you're not using the gtkmm bindings, you're trying to mix C and C++ together.

I think you wanted button.set text() or something similar.

Cheers,

Kevin

On 2013-07-09 11:15 PM, "Chris Share" <cpsmusic yahoo com> wrote:
Hi,

I'm a complete beginner with respect to gtk and gtkmm.

I'd like to add a gtkmm gui to a command line application that I've developed.

As a starting point, I've created a simple demo app with a button. I'd like to change the button's text each time it's clicked.

The button is declared in the app's main window as

Gtk::Button start;

When it's clicked I'd like to change its text as shown below:

void MainWindow::on_play_button_clicked() {
    
    std::cout << "Play" << std::endl;
    
    if(state == 0) {
        gtk_button_set_label(GTK_BUTTON(start), "Stop");
    } else {
 gtk_button_set_label(GTK_BUTTON(start), "Start");
    }
}

What I can't figure out is the actual code to get this to work.

When I build the code I get the following error:

MainWindow.cpp: In member function ‘void MainWindow::on_play_button_clicked()’:
MainWindow.cpp:31: error: invalid cast from type ‘Gtk::Button’ to type ‘GTypeInstance*’
make: *** [metro] Error 1

What am I doing wrong here?

Cheers,

Chris


_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]