Important: Please read the Qt Code of Conduct -


  • Hi everyone,
    Today, I am stuck on a part of my code, I have no idea why. In fact this is due to a bad I/O connection, I tried to debug it but I can't manage to find my error. I have a mainwindow and Findwin is a QDialog. Here's the code:
    @void Mainwin::findinpage()
    Findwin findwin(this);
    qDebug() << "Step 1 done";

    void Mainwin::findnow(QString text)
    qDebug() << "ima in findnow and imma gonna look for " << text;

    This is written is Mainwin.cpp and here is some Findwin.h

    @class Findwin : public QDialog
    explicit Findwin(QWidget *parent = 0);

    void stringComplete(QString);

    public slots:
    void emitit();


    and finally the Findwin.cpp

    @Findwin::Findwin(QWidget *parent) : QDialog(parent)
    //Some layout things...
    //but is a QPushButton


    void Findwin::emitit()
    qDebug() << "emitting Stringcomplete with " << this->findChild<QLineEdit*>()->text();
    emit stringComplete(this->findChild<QLineEdit*>()->text());

    And what I get in the Qt log is

    emitting Stringcomplete with "en"
    Step 1 done

    So in fact, I never enter Mainwin::findnow even with connect(&findwin,SIGNAL(stringComplete(QString)),this,SLOT(findnow(QString))) so what am I supposed to do?

    Thank you very much for every answer you bring

  • Try connecting your signal before calling EXEC method from the findwin class. In your Mainwin::findinpage() function.

    Basically change that function to this:
    @void Mainwin::findinpage()
    Findwin findwin(this);

    qDebug(&#41; << "Step 1 done";    


    As far as I know EXEC, will stop the main loop, and won't connect the signal

    I'm not even sure, whether you need QObject namespace before connect, it depends how you defined the Mainwin class

  • Ok thank you so much it works. You should be a pro to know such things like that ;)

Log in to reply