RE: [gtkmm] Gtk::Image



Thanks! I had a similar example, except I forgot to add(Image).
Now I also need to have a drawing area, and have the Image displayed in
the drawing area. I can only add one widget to the main window, and I
don't know how to display the image unless I add(Image) to the main
window, then show() it. How would I do that?

By the way, where's the demo?

Thanks for the help!



On Fri, 13 Jun 2003, Fredrik Arnerup wrote:

> Citerar "" <Murray Cumming Comneon com>:
> > > From: Silviu D Minut [mailto:minutsil cse msu edu]
> > > Do you have an example?
> >
> > If there isn't one in the examples directory, then there is certainly one in
> > the demo.
>
> Well, I made one anyway. As you can see, it's really not that hard.
>
> /Fredrik Arnerup
>
> -----------------------
> // Gtk::Image example by Fredrik Arnerup (e97_far e kth se)
> // build with
> // g++ -o imageexample imageexample.cc $(pkg-config --cflags --libs gtkmm-2.0)
> #include <gtkmm.h>
> #include <iostream>
>
> class Window: public Gtk::Window {
> public:
>   Window(const std::string &filename) {
>     set_title(filename);
>     add(*manage(new Gtk::Image(filename)));
>     show_all();
>   }
> };
>
> int main(int argc, char **argv) {
>   if(argc == 2) {
>     Gtk::Main kit(argc, argv);
>     Window window(argv[1]);
>     Gtk::Main::run(window);
>   } else std::cerr << "usage: " << argv[0] << " imagefile" << std::endl;
>   return 0;
> }
>




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