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. Does QTreeView have TouchEvents or not?

Does QTreeView have TouchEvents or not?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
9 Posts 2 Posters 1.7k 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.
  • DrageFabeldyrD Offline
    DrageFabeldyrD Offline
    DrageFabeldyr
    wrote on last edited by
    #1

    I'm trying to port my QWidget based project from Windows to Android
    i have QTreeView and right-mouse-button-menu and i want to make this menu open when i touch this QTreeView on my phone
    i've tried few variants but it still has no reaction when i touch the screen

    raven-worxR 1 Reply Last reply
    0
    • DrageFabeldyrD DrageFabeldyr

      I'm trying to port my QWidget based project from Windows to Android
      i have QTreeView and right-mouse-button-menu and i want to make this menu open when i touch this QTreeView on my phone
      i've tried few variants but it still has no reaction when i touch the screen

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

      @DrageFabeldyr said in Does QTreeView have TouchEvents or not?:

      i have QTreeView and right-mouse-button-menu and i want to make this menu open when i touch this QTreeView on my phone

      Follow the Image Gestures Example analogous with the QTabAndHoldGesture and open the menu.
      There is no default implementation which does that for you already for touch events.

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

      DrageFabeldyrD 1 Reply Last reply
      2
      • raven-worxR raven-worx

        @DrageFabeldyr said in Does QTreeView have TouchEvents or not?:

        i have QTreeView and right-mouse-button-menu and i want to make this menu open when i touch this QTreeView on my phone

        Follow the Image Gestures Example analogous with the QTabAndHoldGesture and open the menu.
        There is no default implementation which does that for you already for touch events.

        DrageFabeldyrD Offline
        DrageFabeldyrD Offline
        DrageFabeldyr
        wrote on last edited by
        #3

        @raven-worx thanx, seems i'm starting to get what i want

        1 Reply Last reply
        0
        • DrageFabeldyrD Offline
          DrageFabeldyrD Offline
          DrageFabeldyr
          wrote on last edited by DrageFabeldyr
          #4

          and if i have two QTreeViews on my widget is it possible to recognize on which one i TapAndHold?
          it seems that it's impossible to do by gesture->position

          raven-worxR 1 Reply Last reply
          0
          • DrageFabeldyrD DrageFabeldyr

            and if i have two QTreeViews on my widget is it possible to recognize on which one i TapAndHold?
            it seems that it's impossible to do by gesture->position

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

            @DrageFabeldyr
            simpliest would be when you subclass QTreeView and handle the gesture events there instead in the container widget. Or is there a reason you are handling the event in the container 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

            DrageFabeldyrD 3 Replies Last reply
            0
            • raven-worxR raven-worx

              @DrageFabeldyr
              simpliest would be when you subclass QTreeView and handle the gesture events there instead in the container widget. Or is there a reason you are handling the event in the container widget?

              DrageFabeldyrD Offline
              DrageFabeldyrD Offline
              DrageFabeldyr
              wrote on last edited by DrageFabeldyr
              #6

              @raven-worx i've already thought about that
              both my QTreeViews have their models as subclass, so i think it won't be difficult
              the reason.... i just have all right-mouse-button coding for Windows in container widget but it seems i can't use it twice for gestures too, so i think there is no exact reason
              at least, at this moment

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

                @DrageFabeldyr
                simpliest would be when you subclass QTreeView and handle the gesture events there instead in the container widget. Or is there a reason you are handling the event in the container widget?

                DrageFabeldyrD Offline
                DrageFabeldyrD Offline
                DrageFabeldyr
                wrote on last edited by DrageFabeldyr
                #7

                @raven-worx i'm using "imagegestures" example as basis
                there is in mainwidget.cpp

                void MainWidget::grabGestures(const QList<Qt::GestureType> &gestures)
                {
                    imageWidget->grabGestures(gestures);
                }
                

                in my case it was

                void MainWidget::grabGestures(const QList<Qt::GestureType> &gestures)
                {
                    containerWidget->grabGestures(gestures);
                }
                

                so now it will be

                void MainWidget::grabGestures(const QList<Qt::GestureType> &gestures)
                {
                    containerWidget->firstTreeView->grabGestures(gestures);
                    containerWidget->secondTreeView->grabGestures(gestures);
                }
                

                am i right?

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

                  @DrageFabeldyr
                  simpliest would be when you subclass QTreeView and handle the gesture events there instead in the container widget. Or is there a reason you are handling the event in the container widget?

                  DrageFabeldyrD Offline
                  DrageFabeldyrD Offline
                  DrageFabeldyr
                  wrote on last edited by
                  #8

                  @raven-worx is there any way to do what i want in conteiner widget, because both treeviews connected to each other: all info showing in second depends on highlighted line in the first like groups and elements

                  1 Reply Last reply
                  0
                  • DrageFabeldyrD Offline
                    DrageFabeldyrD Offline
                    DrageFabeldyr
                    wrote on last edited by
                    #9

                    solved by checking vertical coordinate of gesture:

                        if (gesture->state() == Qt::GestureFinished)
                        {
                            if ((gesture->position().y() > TreeView2->pos().y()) && (gesture->position().y() < (TreeView2->pos().y() + TreeView2->height())))
                            {
                                if (!TreeView1->selectionModel()->selectedIndexes().empty()) // you have to select any line in 1 to work with 2
                                    slot_TreeView2_menu();
                            }
                            if ((gesture->position().y() > TreeView1->pos().y()) && (gesture->position().y() < (TreeView1->pos().y() + TreeView1->height())))
                            {
                                    slot_TreeView1_menu();
                            }
                        }
                    
                    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