Results 1 to 3 of 3

Thread: Easy data pipe from many QLineEdits to QStandardModel and QXMLStreamWriter

  1. #1
    Join Date
    Oct 2010
    Posts
    91
    Thanks
    38

    Default Easy data pipe from many QLineEdits to QStandardModel and QXMLStreamWriter

    Hello!

    I am trying to build a low-maintenance-data-pipe from a QDialog's QLineEdits to a QStandardModel or a QXMLStreamWriter.

    So far the quick and dirty solution would be to read all QLineEdits into QStrings and put them into the QStandardModelItem or the QXMLStreamWriter.

    But this is relative unflexible, because I have to do a lot of rewriting if LineEdits are added or removed.

    I thought of setting up a QStringList with names of all QLineEdits and iterate through them to fetch the values. But this still needs some maintance if the QLineEdits change.

    Can someone of you point me to a better solution?
    Pieces of code are welcome

    Kind regards,
    HomeR

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Easy data pipe from many QLineEdits to QStandardModel and QXMLStreamWriter

    Qt Code:
    1. class HandleLineEdits : public SomethingLikeQObject
    2. {
    3. public:
    4. HandleLineEdits();
    5.  
    6. void addLineEdit(QLineEdit *lineEdit);
    7.  
    8. void doSomethingUsefullWithTheLineEdits();
    9.  
    10. private:
    11. QList<QLineEdit *> lineEdits;
    12. };
    To copy to clipboard, switch view to plain text mode 

    Change to your own preference and improve the code (errors).

  3. The following user says thank you to tbscope for this useful post:

    homerun4711 (21st December 2010)

  4. #3
    Join Date
    Oct 2010
    Posts
    91
    Thanks
    38

    Default Re: Easy data pipe from many QLineEdits to QStandardModel and QXMLStreamWriter

    Thank you very much, this looks quite good.
    Always think object-oriented

Similar Threads

  1. Replies: 4
    Last Post: 27th August 2010, 10:27
  2. Creating a Tree Model from a QStandardModel
    By kaushal_gaurav in forum Qt Programming
    Replies: 3
    Last Post: 19th December 2008, 06:47
  3. creating a tree hierarchy using QStandardModel
    By wind in forum Qt Programming
    Replies: 3
    Last Post: 19th September 2006, 21:54
  4. QTreeView and QStandardModel : add children
    By Valheru in forum Newbie
    Replies: 7
    Last Post: 19th September 2006, 17:24
  5. Easy algorithm to encrypt / decrypt string data?
    By Mike in forum Qt Programming
    Replies: 7
    Last Post: 2nd March 2006, 06:42

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.