Any obvious reason why this "connect" fails



  • I'm using Creator (maybe that's important in this case)... but when I run the follow code, the "connect" fails with error msg "Object::connect: No such slot MainWindow::NowLblClicked(QString xxS) in ..\QtSaga\mainwindow.cpp:18" but to my eyes the slot does exist????

    from the mainwindow.h file:

    public slots: void NowLblClicked(QString xxS);

    from the mainwindow.cpp file:

    void MainWindow::NowLblClicked(QString xxS)
    {
    QDate crdate = QDate::currentDate();

    QTime crtime = QTime::currentTime();
    
    
    ui->YearUD->setValue(crdate.year());
    

    The connect statement (from the mainwindow initialization code):

    "connect( ui->NowLbl, S I G N A L(linkActivated(QString)), this, S L O T(NowLblClicked(QString xxS)));"

    What am I missing... I'm sure it's obvious - just I don't see it.

    thanks - greg

    (*) I had to expand out the words signal and slot because the forum is doing something funny if I leave them as in the code ;-( Also, the code lines form the init code - when cut and pasted is several lines, now one single line.



  • Remove xxS parameter name from SLOT.



  • Denis - thanks for the quick reply - remove the xxS in which case? The .h file, the function header in the mainwindow, or the connect? (and yes, I'm very new Qt !!!)

    thanks - greg



  • I removed it from the connect... and I don't get the error msg any more... but when I click the label, the connected to code doesn't seem to get control... Will LinkActivated fire for any label? for any label with underlined text? or does something else have to be specified in the label definition for make it "fire'able"? (the label also has openexternallinks checked, and textInteractionFlags set as LinksAccessibleByMouse)

    again - thanks, greg



  • quote author="DrGreg" date="1280420929" I had to expand out the words signal and slot because the forum is doing something funny if I leave them as in the code ;-( Also, the code lines form the init code - when cut and pasted is several lines, now one single line.[/quote]

    If you wrap your code in two @'s (our code tag) it will get treated much better. :) You can find it on the toolbar as well.



  • Do you have links in your label or underlined text only? You should make them links ("a" tag).



  • Denis - Only underlined text... in building an app for a smartphone, one is always looking for ways to conserve real estate; so, I was trying to make a label act as a pushbutton [have done this lots of times in windows desktop apps in Delphi]... since I'm not really interested in using the label as a real hyperlink... I guess I'll use a real button... but question: where would one put the <a.... > tag in the qlabel definition? And if it's there, will the link be automatically executed, ie, call a browser using it, or will simply my slot be called with the text of the link (which in this case, ignored)?

    again - many thanks - greg



  • If you will set openExternalLinks to false then signal will be emitted. If it will be true then signal will not be emitted, but browser will be opened.



  • Denis - yet again, thank you. If I set openExternalLinks to false, do I still need to set another field to @<a.... >@ to have the signal emitted; or will it happen without the @<a > @ link? The use of the clickable label (mentioned above) I've already change to a very small pushbutton (just to get the prototype up and running)... but for future reference I'm interested [clickable labels make useful less frequently used space-saving pushbuttons... which I'm sure I'll use again.]

    again - thanks, greg



  • Marius - it works as you've said (though I also get line numbers.. is there a way to include html (see above message) and not have it "interpreted", simply included as text?? - again, thanks - greg



  • @DrGreg: You can also use the currently undocumented [ code ] * [ /code ] (without the spaces), that will render most html as something like this:

    [code]
    <ul>
    <li><a href="http://www.forum.nokia.com/Develop/Qt/Tools/">Download the Nokia Qt SDK at Forum Nokia</a></li>
    <li><a href="http://conversations.nokia.com/2010/04/27/nokia-rolls-out-qt-sdk-for-unified-mobile-developer-experience/">The Official Nokia Blog: Nokia rolls out the Nokia Qt SDK for unified
    mobile developer experience</a></li>
    <li><a href="http://labs.trolltech.com/blogs/2010/04/27/nokia-qt-sdk-what-is-in-and-what-is-not-and…-what-is-it/">Qt Labs Blog: Nokia Qt SDK, what is in and what is not and…. What is it?</a></li>
    <li><a href="http://blog.qt.nokia.com/2010/04/27/qt-gets-more-mobil/">Qt Blog: Qt gets more mobile today</a></li>
    <li><a href="http://www.forum.nokia.com/Develop/Qt/">Qt, on Forum Nokia</a></li>
    <li><a href="http://events.nokia.com/NokiaN8/">Nokia N8, comes with Qt</a></li>
    </ul>
    [/code]

    It will still run it through the normal protective filters and have some color applied to it - but it should come out in fairly good shape :)



  • MariusG, oops, this undocumented tag slightly crashed design ;)

    DrGreg, yeah you should use "a" tag to make it working.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.