Results 1 to 13 of 13

Thread: how to connect to a slot when a row is selected in TableView?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2010
    Location
    Singapore
    Posts
    156
    Thanks
    47
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to connect to a slot when a row is selected in TableView?

    Any code example.please.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: how to connect to a slot when a row is selected in TableView?

    Quote Originally Posted by babygal View Post
    Any code example.please.
    Ok, then you posted in the wrong forum. Moved to newbie.

    What have you tried so far? have you red the methods I mentioned? Read the documentation about signal and slots. There is no use if I post code because you have to learn it (also how to learn things right out of the docs.)

  3. #3
    Join Date
    Apr 2010
    Location
    Singapore
    Posts
    156
    Thanks
    47
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to connect to a slot when a row is selected in TableView?

    I think it is returning a valid pointer. And yes I'm using Q_OBJECT macro.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: how to connect to a slot when a row is selected in TableView?

    Did you get any warnings on the console when starting the program?

  5. #5
    Join Date
    Sep 2010
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to connect to a slot when a row is selected in TableView?

    I'm pretty sure that the

    Qt Code:
    1. connect(view->selectionModel(),SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),this,SLOT(querydb()));
    To copy to clipboard, switch view to plain text mode 

    will not work since your signal and your slot don't have the same parameters type. When you connect, you have to connect a signal to a slot with exactly the same parameters.

    Hope this helps.

  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: how to connect to a slot when a row is selected in TableView?

    Quote Originally Posted by Live View Post
    When you connect, you have to connect a signal to a slot with exactly the same parameters.
    That's not true. A slot can have the same parameter count as the signal or lesser but never more.

  7. #7
    Join Date
    Apr 2010
    Location
    Singapore
    Posts
    156
    Thanks
    47
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to connect to a slot when a row is selected in TableView?

    Quote Originally Posted by Lykurg View Post
    Did you get any warnings on the console when starting the program?
    I didn't notice any serious warnings. But the matter got resolved when I combined the table view into my main dialog's layout.

  8. #8
    Join Date
    Jul 2009
    Posts
    92
    Thanks
    7
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to connect to a slot when a row is selected in TableView?

    I think the function must have QIndex in the header:
    this works for me
    connect(fileView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(selectFiles(QModelIndex)));

    void nutshellqt::selectFiles(const QModelIndex& index)
    {

    }

    make sure the function is in the header file under public slots

    public slots:
    void selectFiles(const QModelIndex& index);

Similar Threads

  1. Replies: 3
    Last Post: 6th October 2010, 08:33
  2. Can't connect a signal to a slot
    By cejohnsonsr in forum Newbie
    Replies: 5
    Last Post: 26th August 2010, 20:42
  3. connect a qpushbutton a slot
    By Lycus HackerEmo in forum Newbie
    Replies: 13
    Last Post: 29th March 2010, 09:14
  4. QObject::connect: No such slot !?!
    By Mystical Groovy in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2008, 18:31
  5. Qt Designer & Qt4, connect to my own slot.
    By geitosten in forum Newbie
    Replies: 2
    Last Post: 17th February 2007, 19:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.