Results 1 to 3 of 3

Thread: Class for mapping input widgets

  1. #1
    Join Date
    Oct 2010
    Location
    Poland
    Posts
    26
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Class for mapping input widgets

    I'm making a widget for mapping a QRecord to input widgets. I want to that this new class will be similar in use with QDataWidgetMapper. I create a method
    Qt Code:
    1. addMapping( QWidget* _widget, int _field );
    To copy to clipboard, switch view to plain text mode 

    In this method I want to set a value from record to input control(_widget). How can I do this in right way? My only thing is to make in method a series of dynamic_cast's to discover what a input widget is under _widget pointer. The same issue I have with reading values from input widgets to record - there again I need to know of type widget because I need read value. How to resolve this situation in elegant way?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Class for mapping input widgets

    I believe that QDataWidgetMapper uses the Qt property system and reads/writes the USER property for most widgets. Have a look at the source.

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

    Hostel (13th September 2011)

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Class for mapping input widgets

    To be more exact it uses a QAbstractItemDelegate and its setModelData() and setEditorData() calls that do what Chris said (manipulate the USER property).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    Hostel (13th September 2011)

Similar Threads

  1. Could not get focus on input widgets in mdisubwindow
    By Askar in forum Qt Programming
    Replies: 0
    Last Post: 19th January 2011, 14:29
  2. QModelIndex Mapping in Template QWidget Class
    By stefanadelbert in forum Qt Programming
    Replies: 1
    Last Post: 1st March 2010, 07:19
  3. How to use widgets of other ui within a class???
    By sinha.ashish in forum Qt Programming
    Replies: 1
    Last Post: 10th April 2008, 15:30
  4. Replies: 11
    Last Post: 7th July 2006, 13:09

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
  •  
Qt is a trademark of The Qt Company.