Results 1 to 4 of 4

Thread: read json file data to respective text fields

  1. #1
    Join Date
    Mar 2016
    Posts
    5
    Thanks
    4
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Question read json file data to respective text fields

    Hi,

    I'm new to Qt and i have a question.
    I have a json file (with first name, last name and age). I want to open json file using menu bar and read it to respective text fields (for first name, last name and age ) on mainwindow.

    So how should i read json file data to respective text fields?


    Thanks in advance,
    Shoeb

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: read json file data to respective text fields

    You use QJsonDocument to parse the JSON data, extract the values you need and then call setText() on your text fields.

    Cheers,
    _

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

    shoeb (14th April 2016)

  4. #3
    Join Date
    Mar 2016
    Posts
    5
    Thanks
    4
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: read json file data to respective text fields

    It worked.. thanks


    Added after 6 minutes:


    Hi.. thanks for help.. one more question.. On menu bar under help, i have a shortcut button and after click on that button i want to open new window with list of shortcut's.

    I am able to open new window but not getting how to display list? how should i proceed?

    --Shoeb
    Last edited by shoeb; 14th April 2016 at 12:44.

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: read json file data to respective text fields

    If you mean shortcuts on QActions, then you need some way to get all QActions, e.g. by storing their pointers in a QList member.
    Then you can iterate through that list and get the name shortcut from each and put those into e.g. a QTableWidget

    Cheers,
    _

  6. The following user says thank you to anda_skoa for this useful post:

    shoeb (15th April 2016)

Similar Threads

  1. Data gets overwritten in Json file
    By shoeb in forum Newbie
    Replies: 1
    Last Post: 6th April 2016, 20:57
  2. not able to save form data to json file
    By shoeb in forum Newbie
    Replies: 4
    Last Post: 1st April 2016, 12:23
  3. QlineEdit with constant text and editable text fields
    By arunpk in forum Qt Programming
    Replies: 6
    Last Post: 17th November 2015, 13:38
  4. Replies: 2
    Last Post: 21st February 2013, 07:05
  5. Replies: 8
    Last Post: 8th May 2012, 10:39

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.