Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. DoubleClick in TableView
Forum Updated to NodeBB v4.3 + New Features

DoubleClick in TableView

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 1.0k 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.
  • N Offline
    N Offline
    NotYourFan
    wrote on last edited by
    #1

    Hey i have a TableView.

    Now i want to get a Signal when i make a DoubleClick in the TableView.

    Any Idea?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mpergand
      wrote on last edited by
      #2

      Have a look at QAbstractItemView signals

      1 Reply Last reply
      3
      • N Offline
        N Offline
        NotYourFan
        wrote on last edited by
        #3

        Yes,

        but what should i write in "index" ?

        void doubleClicked(const QModelIndex & index)
        
        jsulmJ 1 Reply Last reply
        0
        • M Offline
          M Offline
          mpergand
          wrote on last edited by VRonin
          #4

          How to connect to:

          connect(tableView,SIGNAL(doubleClicked(QModelIndex)),this, SLOT(doubleClickedTableView(QModelIndex)));
          

          It's old syntax, you can use the new one of course.

          Your slot method should look like this:

          void Myclass::doubleClickedTableView(const QModelIndex &index)
          {
          	QUrl url=index.data(Qt::ToolTipRole).toUrl();  // you retreive the data at the index (here an url)
                // and then emit a signal or do what ever you want
          	if(url.isValid())
          		emit loadUrl(url);  
          }
          
          1 Reply Last reply
          6
          • N NotYourFan

            Yes,

            but what should i write in "index" ?

            void doubleClicked(const QModelIndex & index)
            
            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @notyourfan said in DoubleClick in TableView:

            but what should i write in "index" ?

            Nothing - it's a signal!
            https://doc.qt.io/qt-5/signalsandslots.html

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • N Offline
              N Offline
              NotYourFan
              wrote on last edited by
              #6
              This post is deleted!
              JonBJ 1 Reply Last reply
              0
              • N Offline
                N Offline
                NotYourFan
                wrote on last edited by
                #7

                @jsulm , @mpergand Thank you :)

                1 Reply Last reply
                0
                • N NotYourFan

                  This post is deleted!

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #8

                  @notyourfan

                  Where should i connect this signal?
                  In my Model?

                  You can call the connect() anywhere that the necessary variables/functions you specify are visible. So it does not have to be "inside" anything in particular, most people put connections somewhere in their start up of the UI.

                  However, putting it inside the model code area/classes is not a good idea. Models should not need to know anything about views. OTOH, views do need to know about models, so in the view code, or in the calling code which creates the view, would be best.

                  1 Reply Last reply
                  2

                  • Login

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