0
我有gtk :: applicationWindow和openGL小部件。我想在创建和调整大小时查询openGL小部件的大小。这样做是为了补偿高宽比。这是我的代码片段。问题是,当我调整或产卵窗口。 m_glAreaWidth和m_glAreaHeight的值始终为0.该小部件确实产生并作出反应以调整大小,所以我不明白get_allocation
如何给出大小为0的矩形。在gtkmm中获取小部件大小的问题
mainWindow::mainWindow(BaseObjectType* cobject ,const Glib::RefPtr<Gtk::Builder>& builder):
Gtk::ApplicationWindow(cobject),
m_refGlade(builder),
{
//add GLArea Widget
m_TopLayout->pack_start(m_GLArea);
m_GLArea.set_auto_render(true);
signal_size_allocate().connect(sigc::mem_fun(*this, &mainWindow::on_my_size_allocate),false);
//Makes window fill the whole screen
maximize();
show_all();
}
void mainWindow::on_my_size_allocate(Gtk::Allocation& allocation)
{
Gtk::Allocation glAreaAlloc = m_GLArea.get_allocation();
m_glAreaWidth = glAreaAlloc.get_x();
m_glAreaHeight = glAreaAlloc.get_y();
m_GLArea.queue_render();
}