Results 1 to 3 of 3

Thread: Last edited item

  1. #1
    Join Date
    Aug 2007
    Location
    Fresno - Colombia
    Posts
    26
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Last edited item

    Hi, I have a form with many fields, and a findButton, I need make something for identify the last lineEdit edited when I press the findButton. This is for find matches on costumerId, costumerName, or costumerAddress, etc, without have to use a combobox with the possible search fields. Just clic on the lineEdit that you interested, type the string and clic on findButton.

    Here a video
    Last edited by haldrik; 13th May 2012 at 04:47.

  2. #2
    Join Date
    Dec 2010
    Location
    Russia
    Posts
    83
    Thanks
    1
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Last edited item

    One of the ways is to store all of the editable QLineEdit objects' pointers in an index-based table ( hash for instance ) and use its' ids with a signal mapper.
    Also , you'll probably want to use a distinct const pointer that will store this last edited QLineEdit : const QLineEdit* lastEditedField and a private slot void updateLastEditedField( ) connected with a signal mapper (which is connected with a void textChanged ( const QString & text ) signal of those QLineEdit objects ) , this way you'll get a caller's id to retrieve a pointer and set it as a "lastEditedField".

    You can also do it withought any mapping involved , but in this case you'll have to use QObject* QObject::sender () const , but since you'll lose an object's type , you'll also have to make some casts , which i think is not smart.

  3. #3
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Last edited item

    I would say that the find button should take into consideration ALL of the data filled in on the form.

    In any case, the form could provide a slot that gives the search data, e.g. a map of field name to string data QMap<QString, QString>.

    Qt Code:
    1. // form with line edits cpp
    2. void lineeditform::slotGiveSearchData(QMap<QString, QString>& data)
    3. {
    4. // grab data from ui and put in map
    5. }
    6.  
    7. //results.hpp - your widget with find button and search results
    8. class results : QWidget
    9. {
    10. Q_OBJECT
    11. ...
    12.  
    13. private slots:
    14. void slotFind();
    15.  
    16. signals:
    17. signalGetSearchData();
    18. };
    19.  
    20. // results form cpp
    21. results::results(...)
    22. {
    23. // connect find button clicked() to slotFind() slot
    24. // connect signalGetSearchData to slotGiveSearchData on lineedit form
    25. }
    26.  
    27. void results::slotFind()
    28. {
    29. QMap<QString, QString> searchData;
    30. // use signal signalGetSearchData
    31. emit signalGetSearchData(searchData);
    32.  
    33. // we now have the data.
    34.  
    35. // Do your search...
    36. }
    To copy to clipboard, switch view to plain text mode 
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. Replies: 5
    Last Post: 26th October 2014, 12:56
  2. Get data from table view after item was edited?
    By schmimona in forum Qt Programming
    Replies: 7
    Last Post: 8th September 2011, 12:47
  3. QSpinbox can not be edited through keyboard on Linux
    By sanjayshelke in forum Qt Programming
    Replies: 0
    Last Post: 28th May 2008, 09:21
  4. QTreeWidget - Edited Rows
    By Preeteesh in forum Qt Programming
    Replies: 5
    Last Post: 18th June 2007, 16:44
  5. How to know when field is edited within QTableView
    By dkite in forum Qt Programming
    Replies: 3
    Last Post: 1st January 2007, 18:51

Tags for this Thread

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.