Results 1 to 8 of 8

Thread: QDataWidgetmapper

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jan 2007
    Posts
    38
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDataWidgetmapper

    Thanks for your attention wysota. This what i have tried to do so far:

    Qt Code:
    1. x::x(QWidget *parent, Qt::WFlags flags)
    2. : QMainWindow(parent, flags)
    3. {
    4. setupUi(this);
    5.  
    6.  
    7.  
    8. QSqlTableModel *model = new QSqlTableModel(this);
    9. model->setTable("user_info");
    10.  
    11.  
    12.  
    13. QDataWidgetMapper *mapper = new QDataWidgetMapper(this);
    14. mapper->setModel(model);
    15.  
    16. mapper->addMapping(spinBox, 0);
    17. mapper->addMapping(lineEdit, 1);
    18. mapper->addMapping(lineEdit_2, 2);
    19. mapper->addMapping(spinBox_2, 3);
    20. mapper->toFirst();
    To copy to clipboard, switch view to plain text mode 

    Class "x" inherits a form that i created. This form was created in designer with the editors (lineEdit, lineEdit_2,ect) that were mapped to "mapper".

    The code above is the constructor for class "x". Below is the declaration for class "x".

    Qt Code:
    1. #ifndef X_H
    2. #define X_H
    3.  
    4. #include <QtGui/QMainWindow>
    5. #include "ui_x.h"
    6.  
    7. class x : public QMainWindow,public Ui_xClass
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. x(QWidget *parent = 0, Qt::WFlags flags = 0);
    13. ~x();
    14.  
    15.  
    16. };
    To copy to clipboard, switch view to plain text mode 

    This was simply an attempt to get QDatawidgetmapper to work as explained in the docs, but i would really like to use it in my project.

    my connections to the database were done in main, and works fine as i tested it by assigning the model to a QTableView, and the information came up. Nothing comes up in the widgets that were mapped though.
    Attached Files Attached Files

Similar Threads

  1. QDataWidgetMapper <=> QComboBox best practice
    By saknopper in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2007, 10:50

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.