#include// Create a label widget and set its size to 100x50 pixels QLabel *label = new QLabel("Hello World", parent); label->setFixedSize(100, 50);
#includeThese codes examples are part of the Qt library which is a cross-platform application framework.// Create a spinbox widget and connect its valueChanged signal to a slot QSpinBox *spinBox = new QSpinBox(parent); QObject::connect(spinBox, SIGNAL(valueChanged(int)), parent, SLOT(changeSize(int))); // Slot function that changes the size of the parent widget void Widget::changeSize(int value) { resize(value, value); }