Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt for android
Forum Update on Monday, May 27th 2025

Qt for android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 5 Posters 2.1k Views
  • 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.
  • D Offline
    D Offline
    diva
    wrote on 8 Sept 2017, 09:53 last edited by
    #1

    how to port existing qwidget application to android device using qt ?
    description
    I have one desktop application developed using QT qwidget feature.how can i port this application to android devices without any code changes? is there any way out ? or i should try the qt quick application feature ?.also which one is better qt quick or qwidget?

    K 1 Reply Last reply 8 Sept 2017, 10:16
    0
    • D diva
      8 Sept 2017, 09:53

      how to port existing qwidget application to android device using qt ?
      description
      I have one desktop application developed using QT qwidget feature.how can i port this application to android devices without any code changes? is there any way out ? or i should try the qt quick application feature ?.also which one is better qt quick or qwidget?

      K Offline
      K Offline
      koahnig
      wrote on 8 Sept 2017, 10:16 last edited by
      #2

      @diva

      Assuming that your application is already suitable for typical android screen sizes, you can recompile your application and run it on Android.

      Also the use of simple C++ GUI features is possible. AFAIK the use of Qt Quick provides you better visual appearances for your GUI. At least that my conclusions after my post here I had found a couple of posts outside of this forum addressing similar issues, but answers referred only to Qt quick.

      I would love to get corrected on current view.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        diva
        wrote on 8 Sept 2017, 11:04 last edited by
        #3

        @koahnig thanks for your reply.actually iam able to compile the application to android platform and it is producing .apk also, but the problem is application is crashing when it is installed on the android device.according to me it is not suitable for android screen sizes.how can i make it suitable for android screen ?.what is your opinion?

        R 1 Reply Last reply 8 Sept 2017, 11:12
        0
        • D diva
          8 Sept 2017, 11:04

          @koahnig thanks for your reply.actually iam able to compile the application to android platform and it is producing .apk also, but the problem is application is crashing when it is installed on the android device.according to me it is not suitable for android screen sizes.how can i make it suitable for android screen ?.what is your opinion?

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 8 Sept 2017, 11:12 last edited by raven-worx 9 Aug 2017, 11:14
          #4

          @diva said in Qt for android:

          how can i make it suitable for android screen

          check the screen size and resize it accordingly.

          QScreen *screen = QApplication::screens().at(0);
          screen->availableSize();
          

          Also you may want to read this.

          but the problem is application is crashing when it is installed on the android device

          see the logcat (via adb) on the device. It will show you where exactly it crashed.

          1. connect via adb to your device
          2. start logcat (maybe clear it's buffer make the searching easier)
          3. start your apk
          4. after it crashed, inspect the logcat

          --- 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

          1 Reply Last reply
          2
          • D Offline
            D Offline
            diva
            wrote on 9 Sept 2017, 12:21 last edited by diva 9 Sept 2017, 12:31
            #5

            HI, i tried your solution you have provided i got the following error
            F libc : Fatal signal 11 (SIGSEGV), code 2, fault addr 0xf2b32000 in tid 6958 (QtThread)

            application works on desktop ,but crashing on android emulator.

            following is the code with which i had tried
            mainwindow.cpp

            #include "mainwindow.h"
            #include "ui_mainwindow.h"
            #include <QScreen>
            MainWindow::MainWindow(QWidget *parent) :
                QMainWindow(parent),
                ui(new Ui::MainWindow)
            {
                ui->setupUi(this);
                QScreen *screen = QApplication::screens().at(0);
                screen->availableSize();
            }
            
            MainWindow::~MainWindow()
            {
                delete ui;
            }
            

            main.cpp

            #include "mainwindow.h"
            #include <QApplication>
            
            int main(int argc, char *argv[])
            {
                QApplication a(argc, argv);
                MainWindow w;
                w.show();
            
                return a.exec();
            }
            

            [edit:koahnig: code tags added]

            M 1 Reply Last reply 10 Sept 2017, 07:46
            0
            • D diva
              9 Sept 2017, 12:21

              HI, i tried your solution you have provided i got the following error
              F libc : Fatal signal 11 (SIGSEGV), code 2, fault addr 0xf2b32000 in tid 6958 (QtThread)

              application works on desktop ,but crashing on android emulator.

              following is the code with which i had tried
              mainwindow.cpp

              #include "mainwindow.h"
              #include "ui_mainwindow.h"
              #include <QScreen>
              MainWindow::MainWindow(QWidget *parent) :
                  QMainWindow(parent),
                  ui(new Ui::MainWindow)
              {
                  ui->setupUi(this);
                  QScreen *screen = QApplication::screens().at(0);
                  screen->availableSize();
              }
              
              MainWindow::~MainWindow()
              {
                  delete ui;
              }
              

              main.cpp

              #include "mainwindow.h"
              #include <QApplication>
              
              int main(int argc, char *argv[])
              {
                  QApplication a(argc, argv);
                  MainWindow w;
                  w.show();
              
                  return a.exec();
              }
              

              [edit:koahnig: code tags added]

              M Offline
              M Offline
              mvuori
              wrote on 10 Sept 2017, 07:46 last edited by
              #6

              As Android has only one screen, there is no need to use screens() . I wouldn't be surprised it it crashes or returns null, making the next call crash...

              If your code without it crashes, find out why. Of course it shouldn't crash when it is installed. No QMainWindow-related code will be executed when an app is installed.

              Make sure your UI code uses layouts and no hard coded dimensions. If it fails during execution, run it step by step in debugger to see where exactly it fails.

              1 Reply Last reply
              0

              6/6

              10 Sept 2017, 07:46

              • Login

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