[Qt-interest] QLineEdit textChanged Signal problem !

Thiago Alencar thiago777 at gmail.com
Sat Nov 28 11:31:35 CET 2009


Hi Shankar,

Looking at your code I would expect the script to be executed only
when "button" is clicked, but perhaps there is another call to
"flash()" somewhere else, for example in the Welcome class
constructor(?)
I cant tell much without seeing the whole code..but hope this helps.

BR,
Thiago F. Alencar

On 11/25/09, Shankar Narayana <shank.nasa at gmail.com> wrote:
> Hi Thiago,
>   Thanks a lot. I started playing with your idea. I found out an error which
> I made with my shell script. I could pass the values properly and get it
> displayed. But, my shell script gets executed before my output (in setVal
> function) gets printed on the screen. I dont understand why it happens this
> way.
>  Thanks once again for your hint :)
>
> Regards,
> Shankar Narayana
>
>
> On Wed, Nov 25, 2009 at 5:38 PM, Thiago Alencar <thiago777 at gmail.com> wrote:
>
>> Hi!
>>
>> Have you tried preceding all the white spaces with "\" before sending
>> the command? E.g.:
>>
>> stringFromLineEdit.replace(" ","\ ");
>>
>> Hope it helps!
>> BR/Thiago
>>
>> On 11/25/09, Shankar Narayana <shank.nasa at gmail.com> wrote:
>> > 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
>> >
>>
>> --
>> Sent from my mobile device
>>
>

-- 
Sent from my mobile device



More information about the Qt-interest-old mailing list