Beginner Question: Changing the Text of a Button
- From: Chris Share <cpsmusic yahoo com>
- To: "gtkmm-list gnome org" <gtkmm-list gnome org>
- Subject: Beginner Question: Changing the Text of a Button
- Date: Tue, 9 Jul 2013 20:15:06 -0700 (PDT)
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]