Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29

Thread: Solving some errors.

  1. #21
    Join Date
    Feb 2009
    Posts
    143
    Thanks
    8

    Default Re: Solving some errors.

    thanks a lot mate. it fixed my problem.


  2. #22
    Join Date
    Feb 2009
    Posts
    143
    Thanks
    8

    Default Re: Solving some errors.

    How can i get the input from the users??

    i have used this code

    Qt Code:
    1. void Dialog::gettext()
    2. {
    3. QString text = QInputDialog::getText(this, tr("Enter the username"),
    4. tr("User name:"), QLineEdit::Normal);
    5. ui->dislabel->setText(text);
    6. }
    To copy to clipboard, switch view to plain text mode 

    but this code pops up a dialog which i dont need.

    What i want is, when i add the text in the lineedit, it should be reflected in the label, or

    when i add the text in the lineedit, a variable names text has to store it.

  3. #23
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: Solving some errors.

    so, you need to add QLineEdit to your form and then
    Qt Code:
    1. ...
    2. connect(ui->lineEdit, SIGNAL(textEdited(const QString &)), ui->label, SLOT(setText(const QString &)));
    3. ...
    To copy to clipboard, switch view to plain text mode 
    this code will add a text from lineEdit to label.

    Qt Code:
    1. ...
    2. connect(ui->pushButton, SIGNAL(clicked()), SLOT(getLineEditText()));//get text by clicking on a button
    3. connect(ui->lineEdit, SIGNAL(editingFinished()), SLOT(getLineEditText()));//get text by pressing enter in a lineEdit
    4. //you can also use QLineEdit::returnPressed insted of QLineEdit::editingFinished
    5. ...
    6.  
    7. void MyWidget::getLineEditText()
    8. {
    9. qDebug() << ui->lineEdit->text();
    10. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  4. #24
    Join Date
    Feb 2009
    Posts
    143
    Thanks
    8

    Default Re: Solving some errors.

    Quote Originally Posted by spirit View Post
    so, you need to add QLineEdit to your form and then
    Qt Code:
    1. ...
    2. connect(ui->lineEdit, SIGNAL(textEdited(const QString &)), ui->label, SLOT(setText(const QString &)));
    3. ...
    To copy to clipboard, switch view to plain text mode 
    thanks fore replying

    in the above code, say, if i want to store the text in a variable, how can i do it?

  5. #25
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: Solving some errors.

    use second variant
    Qt Code:
    1. ...
    2. connect(ui->pushButton, SIGNAL(clicked()), SLOT(getLineEditText()));//get text by clicking on a button
    3. connect(ui->lineEdit, SIGNAL(editingFinished()), SLOT(getLineEditText()));//get text by pressing enter in a lineEdit
    4. //you can also use QLineEdit::returnPressed insted of QLineEdit::editingFinished
    5. ...
    6.  
    7. void MyWidget::getLineEditText()
    8. {
    9. const QString myVar = ui->lineEdit->text();
    10. ui->label->setText(myVar);
    11. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  6. #26
    Join Date
    Feb 2009
    Posts
    143
    Thanks
    8

    Default Re: Solving some errors.

    thanks mate. you have helped me alot.

  7. #27
    Join Date
    Feb 2009
    Posts
    143
    Thanks
    8

    Default Re: Solving some errors.

    mate if i want o add a icon into the application, how can it be done?

    I have seen .qrc files. I need to store the image in this particular file

    The icon i am talking about is the one is that tiny icon that appears at the top left corner of an application.

  8. #28
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: Solving some errors.

    read this.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  9. #29
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: Solving some errors.

    I think that you should take closer look into Qt Exapmples & Demos and Qt Assistant. There are a lot of exapmples and explanations to all problems you posted here, and it's quite easy find answers there.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

Similar Threads

  1. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 14:43
  2. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 13:57
  3. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 03:49
  4. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 13:19
  5. Qt-x11-commercial-src-4.2.0-snapshot-20060824 error
    By DevObject in forum Installation and Deployment
    Replies: 4
    Last Post: 25th August 2006, 00:31

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
  •  
Qt is a trademark of The Qt Company.