Results 1 to 5 of 5

Thread: Quick Help Needed with little App.

  1. #1
    Join Date
    Dec 2006
    Location
    Belgium
    Posts
    8
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Quick Help Needed with little App.

    I need to make something that converts from Celcious to:
    Kelvin, Fahrenheit, Rankine, Réaumur, Newton, Rømer and Delisle.

    Right now, I have the following:

    Qt Code:
    1. void mainForm::convertClicked()
    2. {
    3. double celsius_input, result = 0;
    4.  
    5. celsius_input = celsiusLineEdit->text().toDouble();
    6.  
    7. result = (celsius_input * (9.0/5.0)) + 32.0;
    8.  
    9. resultLineEdit->setText(QString::number(result, 'f', 1));
    10.  
    11. celsiusLineEdit->clear();
    12. }
    To copy to clipboard, switch view to plain text mode 

    The problem is, all results have to come in that same resultLineEdit.
    How do I do that?

    Thanks.

  2. #2
    Join Date
    Dec 2006
    Location
    Belgium
    Posts
    8
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Quick Help Needed with little App.

    Please, this is urgent.. Anyone?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Quick Help Needed with little App.

    Quote Originally Posted by Sicko View Post
    Please, this is urgent..
    Never and I mean never say something is urgent if you want a fast reply

    How do you want to display all values in the same lineedit? And why a line edit and not a QLabel?

    Try this:
    Qt Code:
    1. float cel=0, kel=273.15, fahr=32.0; // make those members of your form
    2.  
    3. void mainForm::convert(){ // a slot
    4. double input; // gather input here
    5. bool fromCelsius = celsiusLineEdit->text().isEmpty() ? false : true;
    6. // do the conversion
    7. if(fromCelsius){
    8. input = celsiusLineEdit->text().toDouble();
    9. cel = input; // from Celsius
    10. } else {
    11. input = kelvinLineEdit->text().toDouble();
    12. cel = input + 273.15; // from Kelvin
    13. }
    14. kel = 273.15+cel;
    15. fahr = (9.0/5.0)*cel+32;
    16. label->setText(QString("%1K, %2 deg. C, %3 deg. F").arg(kel).arg(cel).arg(fahr));
    17. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Dec 2006
    Location
    Belgium
    Posts
    8
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Quick Help Needed with little App.

    We have to use a textedit ...
    Thanks (for the fast) reply tho

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Quick Help Needed with little App.

    Quote Originally Posted by Sicko View Post
    We have to use a textedit ...
    Last time you said line edit... You can apply the answer the same way though.

Similar Threads

  1. Help needed with QAbstractItemModel
    By Harvey West in forum Qt Programming
    Replies: 11
    Last Post: 27th November 2006, 12:06
  2. The Methods of quick search...
    By Xagen in forum General Discussion
    Replies: 1
    Last Post: 27th February 2006, 19:09
  3. QProcess start automaticaly needed application
    By raphaelf in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2006, 14:11
  4. qt windows help needed
    By dave in forum Newbie
    Replies: 19
    Last Post: 1st February 2006, 08:24
  5. Help with QHttp needed.
    By bitChanger in forum Qt Programming
    Replies: 5
    Last Post: 25th January 2006, 21:09

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.