Results 1 to 5 of 5

Thread: clearing lineEdits

  1. #1
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default clearing lineEdits

    Hi, I've got a question. In my program I have about 200 lineEdit's. And implementation of actionNew would be
    Qt Code:
    1. lineEdit_number->clear();
    To copy to clipboard, switch view to plain text mode 
    for each other. Is any method to to this by one or few lines of code?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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: clearing lineEdits

    Qt Code:
    1. for(int i=0;i<100;i++) lineEdit[i]->clear();
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: clearing lineEdits

    QObject::findChildren() could be abused like this:
    Qt Code:
    1. foreach (QLineEdit* lineEdit, findChildren<QLineEdit*>())
    2. lineEdit->clear();
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  4. The following user says thank you to jpn for this useful post:

    jaca (13th May 2008)

  5. #4
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: clearing lineEdits

    Than's, that's really useful

  6. #5
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: clearing lineEdits

    But there's something wrong... Before adding this foreach loop which jpn gave mi, program was compiling in 30 seconds. After adding it, it could not compile within 15 minutes!! And it's not finished yet, I'm still waiting for the end of compilation What's wrong?

Similar Threads

  1. Clearing of data in TextEdit
    By keshab in forum Newbie
    Replies: 3
    Last Post: 15th December 2006, 11:29
  2. Clearing QDateEdit
    By jpujolf in forum Qt Programming
    Replies: 3
    Last Post: 27th July 2006, 21:19
  3. QSqlQuery.clear() not clearing?
    By GreyGeek in forum Qt Programming
    Replies: 6
    Last Post: 6th May 2006, 16:06
  4. Clearing QTable
    By Lebowski in forum Newbie
    Replies: 1
    Last Post: 20th April 2006, 08:24
  5. What's the correct way of clearing a pixmap?
    By karye in forum Qt Programming
    Replies: 4
    Last Post: 19th January 2006, 17:46

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.