Re: Clock widget not showing when put in Gtk::Grid.



I printed the width and height values in Clock::on_draw().
With the original code: width=200, height=200
After adding a Grid, like you've done: width=1, height=1
After I also added
   c.set_hexpand();
   c.set_vexpand();
in main.cc: width=200, height=200

On 2020-08-05 20:55, Carlo Wood wrote:
Hi all,

I did
https://developer.gnome.org/gtkmm-tutorial/stable/sec-drawing-clock-example.html.en
which worked.

Then I changed main.cc to:

#include "clock.h"
#include <gtkmm/application.h>
#include <gtkmm/window.h>
#include <gtkmm.h>

int main(int argc, char** argv)
{
   auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example");

   Gtk::Window win;
   win.set_title("Cairomm Clock");

   Gtk::Grid m_grid;
   Clock c;
   m_grid.add(c);
   win.add(m_grid);
   c.show();
   m_grid.show();

   return app->run(win);
}

But this just gives a totally empty window. The clock is gone.
How can I fix this?

Carlo


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