[Qt-interest] QLineEdit textChanged Signal problem !

Shankar Narayana shank.nasa at gmail.com
Wed Nov 25 03:40:16 CET 2009


Hi all,
 I have created a text field using QLineedit for holding name of a person. I
have connected the textchanged() signal to a function which stores the value
to  a string. When I press the submit button, this text value is passed as
an argument to a shell script. When I enter the name with space inbetween,
the textchanged() signal stops firing and my shell script executes only with
the first name instead of full name. When I try to print the result to the
screen, the shell script executes first and then, cout works and displays
proper result. I feel there is some lagging in the firing of the QLineedit
signal and Qbutton signal. Can somebody help me with this issue.

   My code is as follows :
int main(int argc, char* argv[])
{
    Welcome wl;
    QApplication *app = new QApplication(argc,argv);
    return wl.show(app);
}

int Welcome::show(QApplication *app){
    QWidget widgt, widgt_butn;
    widgt.setStyleSheet("QWidget{background: url(./GUI_title1.png)
color(white) }  QLineEdit { background: none } QLabel { font: bold 14px ;
background: none}");
    widgt.move(280,200);

    // Widget sizes
    widgt.resize(720,625);

    // Initializing the buttons in the welcome screen

    QPushButton button("Submit value",&widgt);
    QPushButton button1("Quit",&widgt);
    QLineEdit nametxt;
    nametxt.setParent(&widgt);
    QLabel name_label("Name * :", &widgt);


    // Establishing the link to the next windows once buttons are pressed.
SIGNAL-SLOT connection in Qt Jargon.
    QObject::connect(&nametxt,SIGNAL(textChanged(const QString
&)),this,SLOT(setVal(const QString &)));
    QObject::connect(&button1,SIGNAL(clicked()),app,SLOT(quit()));
    QObject::connect(&button,SIGNAL(clicked()),this,SLOT(flash()));

    //show the main widget
    widgt.show();
    return app->exec();
}

void Welcome::setVal(const QString &val)
{
   cout << "The value I see" << val.toStdString();
    txtval=val;
}
void Welcome::flash()
{
    QProcess proc;
    QString command="sh try.sh ";
    command= command +txtval;
    command=command.toLower();
    proc.execute(command);
}

Regards,
Shankar Narayana
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091124/42395eb5/attachment.html 


More information about the Qt-interest-old mailing list