Results 1 to 2 of 2

Thread: Different result if slot is called from 'Return' or 'Tab'Key in a QLineEdit.

  1. #1
    Join Date
    Jan 2008
    Location
    Davao City, Philippines
    Posts
    77
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Different result if slot is called from 'Return' or 'Tab'Key in a QLineEdit.

    Guys and - of course - girls,

    I'm going crazy today so I hope somebody can help me ...

    With this code
    Qt Code:
    1. QObject::connect ( lineEditRabatt,
    2. SIGNAL( editingFinished() ), this,
    3. SLOT( showPreis() ));
    To copy to clipboard, switch view to plain text mode 
    this slot is called ....

    Qt Code:
    1. void Angebot::showPreis()
    2. {
    3. qDebug() << "I'm in showPreis() now to recalculate the final price ...";
    4.  
    5. lineEditMenge->setText( QString( "%1" ).arg( lineEditMenge->text().toFloat(), 0, 'f', 2 ) );
    6. lineEditBrutto->setText( QString( "%1" ).arg( lineEditBrutto->text().toFloat(), 0, 'f', 2 ) );
    7.  
    8. if ( lineEditRabatt->text().contains ( QChar( '%' ), Qt::CaseInsensitive ) )
    9. {
    10. lineEditRabatt->setText( QString( "%1" ).arg( ( lineEditBrutto->text().toFloat() * lineEditRabatt->text().remove( QChar( '%' ),
    11. Qt::CaseInsensitive).toFloat() ) / 100, 0, 'f', 2 ) );
    12. }
    13. else
    14. {
    15. lineEditRabatt->setText( QString( "%1" ).arg( lineEditRabatt->text().toFloat(), 0, 'f', 2 ) );
    16. }
    17.  
    18. lineEditNetto->setText( QString( "%1" ).arg( lineEditBrutto->text().toFloat() - lineEditRabatt->text().toFloat(), 0, 'f', 2 ) );
    19. lineEditGesamt->setText( QString( "%1" ).arg( lineEditNetto->text().toFloat() * lineEditMenge->text().toFloat(), 0, 'f', 2 ) );
    20.  
    21. if ( lineEditMenge->text().toFloat() > 0 )
    22. pushButtonBuchen->setEnabled ( true );
    23. }
    To copy to clipboard, switch view to plain text mode 

    And now my problem: After I have entered the amount of 'Rabatt' in lineEditRabatt I will leave the lineEdit either with 'Return' or with 'Tab'. If editingFinished() was caused by the 'Tab-Key' everything is ok. But if the last key was the 'Return-Key', then 'lineEditRabatt->text().toFloat()' is igrnored in row 18. It's not zero, it's really ignored ...

    Any idea where I'm wrong?
    DavaoSOFT, the home of ERPel
    ERPel, das deutsche Warenwirtschaftssystem fuer LINUX
    http://www.davaosoft.com

  2. #2
    Join Date
    Jan 2008
    Location
    Davao City, Philippines
    Posts
    77
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Different result if slot is called from 'Return' or 'Tab'Key in a QLineEdit.

    Got it ...

    There was a QPushButton with 'Return' as a shortcut and the pushButton was executed first.
    DavaoSOFT, the home of ERPel
    ERPel, das deutsche Warenwirtschaftssystem fuer LINUX
    http://www.davaosoft.com

Similar Threads

  1. Slot doesn't get called
    By waynew in forum Qt Programming
    Replies: 7
    Last Post: 18th April 2010, 13:34
  2. QSqlQuery return result
    By arpspatel in forum Qt Programming
    Replies: 2
    Last Post: 9th April 2010, 07:55
  3. QColorDialog always return 0 as a result
    By NoRulez in forum Qt Programming
    Replies: 8
    Last Post: 17th October 2009, 12:06
  4. Slot gets called twice
    By greatgatsby in forum Newbie
    Replies: 7
    Last Post: 20th August 2009, 15:11
  5. SLOT not being called
    By steg90 in forum Qt Programming
    Replies: 4
    Last Post: 6th December 2007, 11:30

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.