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. How declaring and using QOrientableSensorBase class to block the orientation of my tablet
Forum Updated to NodeBB v4.3 + New Features

How declaring and using QOrientableSensorBase class to block the orientation of my tablet

Scheduled Pinned Locked Moved Mobile and Embedded
6 Posts 2 Posters 1.6k 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.
  • L Offline
    L Offline
    lucmath
    wrote on last edited by
    #1

    @
    my .pro
    QT += core gui
    QT += sensors
    TARGET = SecretImage
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    SOURCES +=
    main.cpp
    FenPrincipal.cpp
    LabelClic.cpp
    HEADERS +=
    FenPrincipal.h
    LabelClic.h
    OTHER_FILES +=
    ressources.rc
    RC_FILE = ressources.rc
    RESOURCES +=
    ressourcimages.qrc
    @

    @
    my main.cpp
    #include <QApplication>
    #include "FenPrincipal.h"
    #include <QtSensors>
    int main(int argc,char *argv[])
    {
    QApplication app(argc, argv);

     *the mistake is  here with the terms  'QOrientableSensorBase' has not been declared*
    QOrientableSensorBase::setAxesOrientationMode(QOrientableSensorBase::FixedOrientation); 
    
                                                   
    FenPrincipale fenetrePrincipale(app.desktop()->width(),app.desktop()->height(),0);
    fenetrePrincipale.move(0,0);
    fenetrePrincipale.setStyleSheet("background-color:rgb(220,220,220)");
    fenetrePrincipale.show();
    return app.exec&#40;&#41;;
    

    }
    @

    I don't understand why QOrientableSensorBase class is not included into QtSensors. QOrientableSensorBase doesn't appears in the drop down list when I write #include<QtSensors/ (the list appears just after having writed/)
    I just would like to know what writing in my .pro and in my main.cpp to use the QOrientableSensorBase classe with the function setAxesOrientationMode(QOrientableSensorBase::FixedOrientation). I just want block the orientation of my tablet.
    I work with Qt creator3.1 and Qt 5.2.1.
    Thank you

    [edit: added missing coding tags @ SGaist]

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      This class is not part of QSensors, that's why it can't be found. It's available in the Qt Mobility module which had some parts ported to Qt 5.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lucmath
        wrote on last edited by
        #3

        Hi

        In my .pro, I added
        CONFIG+=mobility
        MOBILITY+= sensors

        but I always can't include QOrientableSensorBase class in my main.cpp.

        I work with Qt creator 3.1 and Qt 5.2.1 perhaps it is necessary to download and config Qt Mobility 1.2 on Qt creator before. If yes, where I can find explanations to do that. If no, what I should put in my .pro and in my main.cpp as #include< QOrientableSensorBase> and QOrientableSensorBase::setAxesOrientationMode(QOrientableSensorBase::FixedOrientation); for satisfaction
        thanks

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          QOrientableSensorBase is not available in Qt 5 but you should have the same result with QSensor and setAxesOrientationMode

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lucmath
            wrote on last edited by
            #5

            Thanks you for your reponse.

            My main.cpp is
            @
            #include <QApplication>
            #include "FenPrincipal.h"
            #include<QOrientationSensor>
            #include <QSensor>

            int main(int argc,char *argv[])
            {
            QApplication app(argc, argv);

            QObject *mobile = new QObject();
            QOrientationSensor *orientationTab = new QOrientationSensor(mobile);
            orientationTab->setAxesOrientationMode(QSensor::FixedOrientation);
            
            FenPrincipale fenetrePrincipale(400,400,0);
            fenetrePrincipale.show();
            
            return app.exec&#40;&#41;;
            

            }
            @

            I have no problem with the compilation, but the screen of my tablet doesn't stay fixed. I think to understand why, but I don't know how correcting it. I must define that my object is effectively my tablet, but I am not be able to do that. Can you help me and correct my main.cpp. I promise you that it will be my last question.

            Best regards

            [edit: added missing coding tags @ SGaist]

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You are leaking memory with your mobile variable that is never deleted and
              you don't start the sensor

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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