Re: Get size of widget
- From: Phil Wolff <adiabat centurylink net>
- To: gtkmm-list gnome org
- Subject: Re: Get size of widget
- Date: Tue, 26 Dec 2017 05:59:23 -0800
A widget's size is negotiated when it is realized. As in one of your
other questions, signal_realized() should help.
On 12/26/2017 01:05 AM, Klaus Rudolph wrote:
I simply want to know which size a widget has. I need this info to set
a ScrolledWindow to a maximum size if the size of the widget is bigger
than the screen.
But all functions I know give a constant value of 1.
#include <iostream>
#include <gtkmm.h>
#include <gtkmm/window.h>
class ExampleWindow: public Gtk::Window
{
Gtk::Button button;
public:
ExampleWindow(): button("Hallo")
{
add(button);
GetSize();
}
void GetSize()
{
std::cout << button.get_width() << " " << button.get_height()
<< std::endl;
std::cout << button.get_allocated_width() << " " <<
button.get_allocated_height() << std::endl;
}
};
int main(int argc, char* argv[])
{
Gtk::Main kit(argc, argv);
ExampleWindow window;
window.GetSize();
window.show_all_children();
window.GetSize();
Gtk::Main::run(window);
return 0;
}
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list
--
It is better to have tried and failed than to have failed to try, but
the result's the same.
— Mike Dennison
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]