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
Forum Updated to NodeBB v4.3 + New Features

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 8 Aug 2017, 09:07 last edited by
    #1

    How to minimize application on backkey pressed in android

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vinod Kuntoji
      wrote on 8 Aug 2017, 09:42 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 8 Aug 2017, 10:21
      0
      • V Vinod Kuntoji
        8 Aug 2017, 09:42

        @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 8 Aug 2017, 10:21 last edited by
        #3

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

        1 Reply Last reply
        0
        • V Offline
          V Offline
          Vinod Kuntoji
          wrote on 8 Aug 2017, 11:05 last edited by Vinod Kuntoji 8 Aug 2017, 11:28
          #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

          2/4

          8 Aug 2017, 09:42

          • Login

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