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 android handling Backbutton pressed
QtWS25 Last Chance

Qt android handling Backbutton pressed

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 2 Posters 2.2k 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.
  • P Offline
    P Offline
    Pradeep Reddy
    wrote on last edited by
    #1

    How to minimize application on backkey pressed in android

    1 Reply Last reply
    0
    • Vinod KuntojiV Offline
      Vinod KuntojiV Offline
      Vinod Kuntoji
      wrote on last edited by
      #2

      @Pradeep-Reddy ,

      void Widget::keyPressEvent(QKeyEvent *event)
      {
      switch (event->key())
      {
      case Qt::Key_Backspace:
      this->showMinimized();
      break;
      default:
      QWidget::keyPressEvent(event);
      }
      }

      C++, Qt, Qt Quick Developer,
      PthinkS, Bangalore

      P 1 Reply Last reply
      0
      • Vinod KuntojiV Vinod Kuntoji

        @Pradeep-Reddy ,

        void Widget::keyPressEvent(QKeyEvent *event)
        {
        switch (event->key())
        {
        case Qt::Key_Backspace:
        this->showMinimized();
        break;
        default:
        QWidget::keyPressEvent(event);
        }
        }

        P Offline
        P Offline
        Pradeep Reddy
        wrote on last edited by
        #3

        @Vinod-Kuntoji
        thanks for reply .. actually i am not using widgets .. i need in qml ..

        1 Reply Last reply
        0
        • Vinod KuntojiV Offline
          Vinod KuntojiV Offline
          Vinod Kuntoji
          wrote on last edited by Vinod Kuntoji
          #4

          @Pradeep-Reddy ,

          Item {
          focus: true
          Keys.onPressed: {
          console.log(event.key)
          if (event.key === Qt.Key_Back) {
          mainWindow.showMinimized();
          event.accepted = true;
          }
          }
          }
          It wont work, but it will print key value.
          something like 16777219.
          I used this value to compare with event key.
          It worked
          if (event.key === 16777219) {
          mainWindow.showMinimized();
          }

          C++, Qt, Qt Quick Developer,
          PthinkS, Bangalore

          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