Results 1 to 10 of 10

Thread: c++/Qt5 Signals and slots

  1. #1
    Join Date
    Oct 2006
    Posts
    105
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default c++/Qt5 Signals and slots

    Hello,

    I'm porting 'Ext2Explore' to Qt5 from Qt4 so I can use parts of it in my program.
    I have one last problem.
    I need to generate a dblClicked signal for the 'tree' and 'list', but
    do not understand the syntax required.
    The program compiles with no errors.
    When compiled for Release it crashes.
    When compiled for Debug, generates the following error/warning.
    Qt Code:
    1. QMetaObject::connectSlotsByName: No matching signal for on_action_item_dbclicked(QModelIndex)
    To copy to clipboard, switch view to plain text mode 
    Can someone help, please?

    Regards
    Qt Code:
    1. Ext2Explore::Ext2Explore(QWidget *parent) : QMainWindow(parent), ui(new Ui::Ext2Explore)
    2. {
    3. ...
    4. connect(ui->tree, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(on_action_item_dbclicked(const QModelIndex &)));
    5. connect(ui->list, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(on_action_item_dbclicked(const QModelIndex &)));
    6. }
    7.  
    8. void Ext2Explore::on_action_item_dbclicked(const QModelIndex &index) //slot
    9. {
    10. ...
    11. }
    12.  
    13. private slots:
    14. void on_action_item_dbclicked(const QModelIndex &index);
    15.  
    16. signals:
    17. //This is where I have no idea??
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: c++/Qt5 Signals and slots

    You can probably ignore that warning.

    The on_something syntax and the "connect by name" comes from the "auto connect" feature that some people use for convenience.
    I.e. a slot named with on_ followed by the object name of a UI element followed by the name of a signal on that object will bet attempted to be connected automatically.

    This is often used by beginners because some tutorials on the Internet do that inspite of being a terrible idea.

    You, on the other hand, have explicit connects. What you could do to avoid the warnining is to rename your slots so that they don't match the pattern anymore.
    E.g onActionItemDoubleClicked()

    Cheers,
    _

  3. #3
    Join Date
    Oct 2006
    Posts
    105
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: c++/Qt5 Signals and slots

    Hello anda_skoa,

    Thanks for that, got rid of the Debug compile warning.
    But!
    Compiled for Release, when I start the program I get:-
    'The program has unexpectedly finished.'

    Any suggestions as to where to start finding the reason for this?

    Regards

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: c++/Qt5 Signals and slots

    If you run the program in the debugger, it should display the call stack trace leading up to the crash.

    Very often such crashes are caused by access to uninitialized pointers.

    Cheers,
    _

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: c++/Qt5 Signals and slots

    The message about "no matching signal" is a bit odd, as the thing it is complaining about is a slot. You need to ensure that qmake has run moc over the HEADERS. Also, this code:
    Qt Code:
    1. connect(ui->tree, SIGNAL(doubleClicked(QModelIndex)),
    2. this, SLOT(on_action_item_dbclicked(const QModelIndex &)));
    3. connect(ui->list, SIGNAL(doubleClicked(QModelIndex)),
    4. this, SLOT(on_action_item_dbclicked(const QModelIndex &)));
    To copy to clipboard, switch view to plain text mode 
    Should probably read
    Qt Code:
    1. connect(ui->tree, SIGNAL(doubleClicked(QModelIndex)),
    2. this, SLOT(on_action_item_dbclicked(QModelIndex)));
    3. connect(ui->list, SIGNAL(doubleClicked(QModelIndex)),
    4. this, SLOT(on_action_item_dbclicked(QModelIndex)));
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Oct 2006
    Posts
    105
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: c++/Qt5 Signals and slots

    Hello,

    Thanks to all who have made suggestions.

    Curiouser and Curiouser (said Alice).

    I pulled the release .exe to a folder on the desktop, added the required .dlls and the program ran fine.
    I wonder if my Qt installation has got screwed.

    Before I reinstall Qt, I will try your suggestions.

    I ran the program in the debugger and got a popup:-
    Executable Failed
    'During startup program exited with code 0xc0000135.'

    Regards

  7. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: c++/Qt5 Signals and slots

    'During startup program exited with code 0xc0000135.'
    A quick google search indicates that this is due to a missing .NET framework. If your release mode exe runs fine, then it probably means you are missing the debug DLLs for the framework. These should have been installed with your copy of the Microsoft compilers, but if not you may have to look around for a download. No idea which of the many versions of .NET framework this could be though.

  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: c++/Qt5 Signals and slots

    The c0000135 error is a generic "DLL not found" error, not something specific to .Net. Given that you clearly have the DLLs present on your system somewhere it seems likely that the environment (mainly PATH) being given to your project when run is missing directories containing matching third-party libraries.

  9. #9
    Join Date
    Oct 2006
    Posts
    105
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: c++/Qt5 Signals and slots

    Hello ChrisW67 and d_stranz,

    I've already checked the error code to see what it ment.
    I installed Dependecy Walker and it shows up a lot of missing .dlls.
    I think I will have to check the source againts a fresh download of ext2explorer.
    I recompiled an old project of mine and everything was OK, so Qt is fine.
    More testing tomorrow.

    Regards

  10. #10
    Join Date
    Oct 2006
    Posts
    105
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: c++/Qt5 Signals and slots

    Hello,

    Thanks to everybody that helped.

    I replaced the hard drive, bak ups and reinstalled some software , everything is fine.
    I'm guessing it was something to do with paths and a dodgy hard drive.

    Rgards

Similar Threads

  1. Signals & slots
    By igoreshka3333 in forum Newbie
    Replies: 10
    Last Post: 20th December 2014, 17:49
  2. Replies: 2
    Last Post: 18th April 2013, 12:15
  3. Signals and Slots
    By ggdev001 in forum Qt Programming
    Replies: 6
    Last Post: 20th February 2013, 12:07
  4. Signals and Slots
    By Maluko_Da_Tola in forum Newbie
    Replies: 3
    Last Post: 29th July 2010, 23:57
  5. Signals and Slots
    By merry in forum Qt Programming
    Replies: 4
    Last Post: 22nd February 2007, 08:11

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.