Results 1 to 3 of 3

Thread: data-aware widgets

  1. #1
    Join Date
    Dec 2008
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question data-aware widgets

    Hi, I'm really a newbe in QT world! I'm creating a software that manage data from a DB and presents it to the user. I'm using some Model/View Widgets but I'd like to connect them with a "datasource"... I mean: I have a comboBox that display a item name, and I like to populate some text-fields with item-details.
    as an expample I have a table with (ID, name, description, price), in my comboBox I need to display only "name" column, and when user chooses another "name" I need to populate some (read-only) text-fields with description and price. Is there any widget that do that "automatically"?

    Regards!

  2. #2
    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: data-aware widgets

    You can use an SQL model with QComboBox, and QDataWidgetMapper might be handy whilst mapping widgets to certain fields.
    J-P Nurmi

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

    thePanz (17th December 2008)

  4. #3
    Join Date
    Dec 2008
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: data-aware widgets

    Thank you so much! For completeness I report a code (found in QT docs) to do what I mean (for future reference)

    Qt Code:
    1. mapper->setModel(model);
    2. mapper->addMapping(mySpinBox, 0);
    3. mapper->addMapping(myLineEdit, 1);
    4. mapper->addMapping(myCountryChooser, 2);
    5. mapper->toFirst();
    To copy to clipboard, switch view to plain text mode 

    Thank you again!

Similar Threads

  1. Best way to display lots of data fast
    By New2QT in forum Newbie
    Replies: 4
    Last Post: 16th October 2008, 22:46
  2. Writing Data Aware Forms in QT4.
    By gsQT4 in forum Qt Programming
    Replies: 5
    Last Post: 21st March 2007, 10:35
  3. Replies: 1
    Last Post: 9th March 2007, 21:07
  4. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.