Re: signal printing to terminal



On 02/05/2012 04:59, Jamie Lahowetz wrote:
> This is probably a fairly easy question but Im very new to c++ and gtkmm and am
> trying to connect a signal to a glade created entry. when return is pressed the
> text is grabbed from the entry and displays in the terminal... only nothing
> happens. A little help would be nice as to what im doing wrong. Thank you.

It looks like you're trying to retrieve a widget from Gtk::Builder and use a
derived class to handle it... only that you're not hooking it all up properly,
so Gtk::Builder does not know about your derived class at all.

Looking at the Gtkmm documentation, it looks like
Gtk::Builder::get_widget_derived() is what you want, rather than
Gtk::Builder::get_widget().

> main.cpp:
> #include <gtkmm.h>
> #include <iostream>
> #include "terminal.h"
> 
> int main(int argc, char *argv[])
> {
> //    required to start application methods
>     Gtk::Main kit(argc, argv);
> 
>     Gtk::Window *mainwindow;

Try using MainWindow *mainwindow; here..

>     //Load the GtkBuilder file
>     Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create();
>     try
>     {
>         refBuilder->add_from_file("
> hprcc.glade");
>     }
>     catch(const Glib::FileError& ex)
>     {
>         std::cerr << "FileError: " << ex.what() << std::endl;
>         return 1;
>     }
>     catch(const Glib::MarkupError& ex)
>     {
>         std::cerr << "MarkupError: " << ex.what() << std::endl;
>         return 1;
>     }
>     catch(const Gtk::BuilderError& ex)
>     {
>         std::cerr << "BuilderError: " << ex.what() << std::endl;
>         return 1;
>     }
> 
> //    get the main window widget
>     refBuilder->get_widget("mainwindow", mainwindow);

and get refBuilder->get_widget_derived ("mainwindow", mainwindow);

> 
> //    start the event loop
>     kit.run(*mainwindow);
> 
>     return 0;
> }
> [...]

-- 
Kind regards,
Loong Jin

Attachment: signature.asc
Description: OpenPGP digital signature



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