Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Positioning Qt Widgets on the screen
Forum Updated to NodeBB v4.3 + New Features

Positioning Qt Widgets on the screen

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    adam.yh.lee
    wrote on last edited by
    #1

    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[])
    {
        Q_INIT_RESOURCE(classwizard);
    
        QApplication app(argc, argv);
    
    #ifndef QT_NO_TRANSLATION
        QString translatorFileName = QLatin1String("qt_");
        translatorFileName += QLocale::system().name();
        QTranslator *translator = new QTranslator(&app);
        if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
            app.installTranslator(translator);
    #endif
    
        ClassWizard wizard;
        wizard.show();
        return app.exec();
    }
    

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

    raven-worxR 1 Reply Last reply
    0
    • A adam.yh.lee

      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[])
      {
          Q_INIT_RESOURCE(classwizard);
      
          QApplication app(argc, argv);
      
      #ifndef QT_NO_TRANSLATION
          QString translatorFileName = QLatin1String("qt_");
          translatorFileName += QLocale::system().name();
          QTranslator *translator = new QTranslator(&app);
          if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
              app.installTranslator(translator);
      #endif
      
          ClassWizard wizard;
          wizard.show();
          return app.exec();
      }
      

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

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

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

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      A 1 Reply Last reply
      0
      • raven-worxR raven-worx

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

        A Offline
        A Offline
        adam.yh.lee
        wrote on last edited by
        #3

        @raven-worx

        Specific location on the screen would do the job.

        raven-worxR 1 Reply Last reply
        0
        • A adam.yh.lee

          @raven-worx

          Specific location on the screen would do the job.

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @adam.yh.lee
          then simply call move() on the top-level widget

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          A 1 Reply Last reply
          3
          • raven-worxR raven-worx

            @adam.yh.lee
            then simply call move() on the top-level widget

            A Offline
            A Offline
            adam.yh.lee
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved