Results 1 to 20 of 22

Thread: Object::connect: No such slot MainWindowImpl::rowClicked(QModelindex)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Object::connect: No such slot MainWindowImpl::rowClicked(QModelindex)

    New to qt, using qdevelop.

    For a few days now I'm trying get an event working when a row is clicked in a tableview.
    I think I have all the syntax right but the event is still not firing and I'm getting out of options.

    In Mainwindow.ui, a signal / slot pair exists that connects the table pressed(QModelIndex) to the MainWindow.

    <sender>table</sender>
    <signal>pressed(QModelIndex)</signal>
    <receiver>MainWindow</receiver>
    <slot></slot>


    Then I have this code, in mainwindowimpl.h

    private slots:
    void rowClicked(const QModelIndex &);

    and in mainwindowimp.cpp:
    in constructor:

    connect(table, SIGNAL(pressed(const QModelIndex &)), this, SLOT(rowClicked(const QModelindex &)));

    member function:

    void MainWindowImpl::rowClicked(const QModelIndex &index)
    {
    int row = index.row();
    QString name = model->record(row).value("name").toString();
    setWindowTitle(name);
    }

    That event does not get called, why not? Voodoo?
    Help is appreciated.
    Last edited by JeanC; 3rd January 2008 at 15:14.

  2. #2
    Join Date
    Dec 2007
    Location
    Austin, TX
    Posts
    43
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Object::connect: No such slot MainWindowImpl::rowClicked(QModelindex)

    Quote Originally Posted by JeanC View Post
    <snip>
    and in mainwindowimp.cpp:
    in constructor:

    connect(table, SIGNAL(pressed(const QModelIndex &)), this, SLOT(rowClicked(const QModelindex &)));
    Have you tried using the signal clicked(const QModelIndex&)? I'm not sure it'll change your results, but it couldn't hurt [ pressed() is for a mouse press, clicked() for a mouse click... ymmv]

    Vycke

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Object::connect: No such slot MainWindowImpl::rowClicked(QModelindex)

    rowClicked(QModelindex)
    and
    rowClicked(const QModelIndex &)
    are not the same.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Object::connect: No such slot MainWindowImpl::rowClicked(QModelindex)

    Thanks folks.

    @vycke
    Yes i tried that, same result, nothing.

    @high_flyer
    I have nowhere 'rowClicked(QModelindex)' in my code, I use the designer and there it's called like that. If you open the ui file in kate yes, but that's done by the designer, isn't it.

    So I'm not clear what you mean.

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Object::connect: No such slot MainWindowImpl::rowClicked(QModelindex)

    why are you defining slots with designer if you don't use them?
    Is the warning that you posted in the subject is the only one you get?

    to make sure that the slot really is not being called, add a debug message, and see if it comes out in the console.
    It could be that the slot is called and for some other reason you don't see the effect you expect.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. #6
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Object::connect: No such slot MainWindowImpl::rowClicked(QModelindex)

    Well I was told this in another thread:

    ---
    void QAbstractItemView:ressed( const & index ) [signal]
    as you can see signal argument type is const QModelIndex & not QModelIndex
    ---

    I tried to drop the const and the & everywhere but no succes.
    I tried qDebug() << "in callback"; but did not show up.

    Thanks.

    First prize goes to the person who solves this riddle.

  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Object::connect: No such slot MainWindowImpl::rowClicked(QModelindex)

    don't define the slot as private, since other objects cant call it.
    make it public.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  8. #8
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Object::connect: No such slot MainWindowImpl::rowClicked(QModelindex)

    Done, no change.

    These I get:
    Object::connect: Parentheses expected, slot MainWindowImpl::
    Object::connect: (sender name: 'actionExit')
    Object::connect: (receiver name: 'MainWindow')
    Object::connect: Parentheses expected, slot MainWindowImpl::
    Object::connect: (sender name: 'table')
    Object::connect: (receiver name: 'MainWindow')
    Object::connect: No such slot MainWindowImpl::rowClicked(QModelindex)
    Object::connect: (sender name: 'table')
    Object::connect: (receiver name: 'MainWindow')

    From this:
    setupUi(this);
    connect(actionExit, SIGNAL(triggered()), this, SLOT(exitClicked()));
    connect(table, SIGNAL(clicked(const QModelIndex &)), this, SLOT(rowClicked(const QModelindex&)));

    That other event, actionExit, is working though.

  9. #9
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Object::connect: No such slot MainWindowImpl::rowClicked(QModelindex)

    From that error you would expect something's wrong with that syntax in the connect() calls.
    removing the const and & still displays Parenthesis expected.

  10. #10
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Object::connect: No such slot MainWindowImpl::rowClicked(QModelindex)

    it should be QModelIndex not QModelindex.

    Where is actionExit defined?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  11. #11
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Object::connect: No such slot MainWindowImpl::rowClicked(QModelindex)

    Good spot!
    It works.!!!

    pfff, thanks a bunch.

Similar Threads

  1. How to declare SLOT as a parameter to member function?
    By QPlace in forum Qt Programming
    Replies: 2
    Last Post: 17th July 2018, 00:41
  2. Replies: 2
    Last Post: 8th October 2007, 15:02
  3. Signal / Slot with specific argument and threads
    By tpf80 in forum Qt Programming
    Replies: 3
    Last Post: 14th September 2007, 23:43
  4. Example HowTo create custom view
    By dexjam in forum Newbie
    Replies: 6
    Last Post: 12th July 2006, 11:06
  5. signal slot conection using a string, not a SLOT
    By rianquinn in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2006, 18:52

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.