C++ (Qt)
class TestQt : public QWidget
{
Q_OBJECT
public:
TestQt(QWidget *parent = 0);
~TestQt();
};
TestQt::TestQt(QWidget *parent)
: QWidget(parent)
{
QGridLayout* layout = new QGridLayout(this);
QPushButton* button1 = new QPushButton("1", this);
QPushButton* button2= new QPushButton("2", this);
QPushButton* button3 = new QPushButton("3", this);
QPushButton* button4 = new QPushButton("4", this);
layout->addWidget(button1, 0, 0);
layout->addWidget(button2, 0, 1);
layout->addWidget(button3, 1, 0);
layout->addWidget(button4, 1, 1);
const QRect rect = childrenRect();
qDebug() << rect;
}
TestQt::~TestQt()
{
}
В выводе получаем QRect(0,0 100x30). Вполне определенные координаты и размеры.