#include#include int main(int argc, char *argv[]) { QApplication app(argc, argv); QMainWindow window; window.resize(600, 400); // set width to 600 pixels window.show(); return app.exec(); }
#includeThese examples use the Qt Core and Qt Widgets modules of the Qt library.#include void printWidgetWidth(QWidget* widget) { qDebug() << "Current width: " << widget->width(); } int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget widget; widget.resize(500, 300); // set initial width printWidgetWidth(&widget); // prints "Current width: 500" widget.resize(800, 300); // resize to new width printWidgetWidth(&widget); // prints "Current width: 800" return app.exec(); }