Positioning Qt Widgets on the screen

  • I am a complete newbie in Qt. I am bringing up a mobile development platform so my software developers can write custom Qt applications. I have successfully brought up Qt-Wayland "minimal-qml" compositor. I can launch widgets from the Qt 5 demo directories. Now I want to be able to place these widgets at a specific location on the screen. Where or how do I go about to do this?

    For example, classwizard demo widget has these files:

    # ls
    classwizard      classwizard.cpp  classwizard.h    classwizard.pro  classwizard.qrc  images           main.cpp

    I have an inkling that main.cpp is the one to make the necessary changes:

    #include <QApplication>
    #include <QTranslator>
    #include <QLocale>
    #include <QLibraryInfo>
    #include "classwizard.h"
    int main(int argc, char *argv[])
        QApplication app(argc, argv);
        QString translatorFileName = QLatin1String("qt_");
        translatorFileName += QLocale::system().name();
        QTranslator *translator = new QTranslator(&app);
        if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
        ClassWizard wizard;
        return app.exec();

    However, my road ends here. I have no idea where to go from here. Help will be definitely appreciated.

  • Moderators

    where do you want to position the window? I mean on a specific coordinate or in a corner/centered on the screen?

  • @raven-worx

    Specific location on the screen would do the job.

  • Moderators

    then simply call move() on the top-level widget

  • @raven-worx great thank you. That's all I needed.

Log in to reply