Qt QTableView多重继承方法

| 我已经在Qt Designer中创建了一个用户界面,现在我想显示数据。我想使用多重继承方法,这是用户界面的代码。
/********************************************************************************
** Form generated from reading UI file \'prototypejI3444.ui\'
**
** Created: Mon May 30 10:04:01 2011
**      by: Qt User Interface Compiler version 4.7.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/

#ifndef PROTOTYPEJI3444_H
#define PROTOTYPEJI3444_H

#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QGridLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QMainWindow>
#include <QtGui/QMenuBar>
#include <QtGui/QPushButton>
#include <QtGui/QStatusBar>
#include <QtGui/QTableView>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>

QT_BEGIN_NAMESPACE

class Ui_MainWindow
{
public:
    QWidget *centralwidget;
    QGridLayout *gridLayout;
    QVBoxLayout *verticalLayout_2;
    QLabel *label;
    QVBoxLayout *verticalLayout_3;
    QLineEdit *lineEdit;
    QVBoxLayout *verticalLayout_4;
    QLabel *label_2;
    QVBoxLayout *verticalLayout_5;
    QLineEdit *lineEdit_2;
    QVBoxLayout *verticalLayout_6;
    QLabel *label_3;
    QVBoxLayout *verticalLayout_7;
    QLineEdit *lineEdit_3;
    QTableView *tableView;
    QPushButton *pushButton_2;
    QPushButton *pushButton_3;
    QPushButton *pushButton_4;
    QPushButton *pushButton_5;
    QPushButton *pushButton_6;
    QPushButton *pushButton;
    QMenuBar *menubar;
    QStatusBar *statusbar;

    void setupUi(QMainWindow *MainWindow)
    {
        if (MainWindow->objectName().isEmpty())
            MainWindow->setObjectName(QString::fromUtf8(\"MainWindow\"));
        MainWindow->resize(800, 600);
        centralwidget = new QWidget(MainWindow);
        centralwidget->setObjectName(QString::fromUtf8(\"centralwidget\"));
        gridLayout = new QGridLayout(centralwidget);
        gridLayout->setObjectName(QString::fromUtf8(\"gridLayout\"));
        verticalLayout_2 = new QVBoxLayout();
        verticalLayout_2->setObjectName(QString::fromUtf8(\"verticalLayout_2\"));
        label = new QLabel(centralwidget);
        label->setObjectName(QString::fromUtf8(\"label\"));

        verticalLayout_2->addWidget(label);


        gridLayout->addLayout(verticalLayout_2, 1, 0, 1, 1);

        verticalLayout_3 = new QVBoxLayout();
        verticalLayout_3->setObjectName(QString::fromUtf8(\"verticalLayout_3\"));
        lineEdit = new QLineEdit(centralwidget);
        lineEdit->setObjectName(QString::fromUtf8(\"lineEdit\"));

        verticalLayout_3->addWidget(lineEdit);


        gridLayout->addLayout(verticalLayout_3, 1, 1, 1, 1);

        verticalLayout_4 = new QVBoxLayout();
        verticalLayout_4->setObjectName(QString::fromUtf8(\"verticalLayout_4\"));
        label_2 = new QLabel(centralwidget);
        label_2->setObjectName(QString::fromUtf8(\"label_2\"));

        verticalLayout_4->addWidget(label_2);


        gridLayout->addLayout(verticalLayout_4, 2, 0, 1, 1);

        verticalLayout_5 = new QVBoxLayout();
        verticalLayout_5->setObjectName(QString::fromUtf8(\"verticalLayout_5\"));
        lineEdit_2 = new QLineEdit(centralwidget);
        lineEdit_2->setObjectName(QString::fromUtf8(\"lineEdit_2\"));

        verticalLayout_5->addWidget(lineEdit_2);


        gridLayout->addLayout(verticalLayout_5, 2, 1, 1, 1);

        verticalLayout_6 = new QVBoxLayout();
        verticalLayout_6->setObjectName(QString::fromUtf8(\"verticalLayout_6\"));
        label_3 = new QLabel(centralwidget);
        label_3->setObjectName(QString::fromUtf8(\"label_3\"));

        verticalLayout_6->addWidget(label_3);


        gridLayout->addLayout(verticalLayout_6, 3, 0, 1, 1);

        verticalLayout_7 = new QVBoxLayout();
        verticalLayout_7->setObjectName(QString::fromUtf8(\"verticalLayout_7\"));
        lineEdit_3 = new QLineEdit(centralwidget);
        lineEdit_3->setObjectName(QString::fromUtf8(\"lineEdit_3\"));

        verticalLayout_7->addWidget(lineEdit_3);


        gridLayout->addLayout(verticalLayout_7, 3, 1, 1, 1);

        tableView = new QTableView(centralwidget);
        tableView->setObjectName(QString::fromUtf8(\"tableView\"));

        gridLayout->addWidget(tableView, 0, 0, 1, 2);

        pushButton_2 = new QPushButton(centralwidget);
        pushButton_2->setObjectName(QString::fromUtf8(\"pushButton_2\"));

        gridLayout->addWidget(pushButton_2, 2, 2, 1, 1);

        pushButton_3 = new QPushButton(centralwidget);
        pushButton_3->setObjectName(QString::fromUtf8(\"pushButton_3\"));

        gridLayout->addWidget(pushButton_3, 3, 2, 1, 1);

        pushButton_4 = new QPushButton(centralwidget);
        pushButton_4->setObjectName(QString::fromUtf8(\"pushButton_4\"));

        gridLayout->addWidget(pushButton_4, 1, 3, 1, 1);

        pushButton_5 = new QPushButton(centralwidget);
        pushButton_5->setObjectName(QString::fromUtf8(\"pushButton_5\"));

        gridLayout->addWidget(pushButton_5, 2, 3, 1, 1);

        pushButton_6 = new QPushButton(centralwidget);
        pushButton_6->setObjectName(QString::fromUtf8(\"pushButton_6\"));

        gridLayout->addWidget(pushButton_6, 3, 3, 1, 1);

        pushButton = new QPushButton(centralwidget);
        pushButton->setObjectName(QString::fromUtf8(\"pushButton\"));

        gridLayout->addWidget(pushButton, 1, 2, 1, 1);

        MainWindow->setCentralWidget(centralwidget);
        tableView->raise();
        pushButton_2->raise();
        pushButton_3->raise();
        pushButton_4->raise();
        pushButton_5->raise();
        pushButton_6->raise();
        pushButton->raise();
        menubar = new QMenuBar(MainWindow);
        menubar->setObjectName(QString::fromUtf8(\"menubar\"));
        menubar->setGeometry(QRect(0, 0, 800, 18));
        MainWindow->setMenuBar(menubar);
        statusbar = new QStatusBar(MainWindow);
        statusbar->setObjectName(QString::fromUtf8(\"statusbar\"));
        MainWindow->setStatusBar(statusbar);

        retranslateUi(MainWindow);

        QMetaObject::connectSlotsByName(MainWindow);
    } // setupUi

    void retranslateUi(QMainWindow *MainWindow)
    {
        MainWindow->setWindowTitle(QApplication::translate(\"MainWindow\", \"MainWindow\", 0, QApplication::UnicodeUTF8));
        label->setText(QApplication::translate(\"MainWindow\", \"FirstName:\", 0, QApplication::UnicodeUTF8));
        label_2->setText(QApplication::translate(\"MainWindow\", \"SecondName:\", 0, QApplication::UnicodeUTF8));
        label_3->setText(QApplication::translate(\"MainWindow\", \"City:\", 0, QApplication::UnicodeUTF8));
        pushButton_2->setText(QApplication::translate(\"MainWindow\", \"New\", 0, QApplication::UnicodeUTF8));
        pushButton_3->setText(QApplication::translate(\"MainWindow\", \"Delete\", 0, QApplication::UnicodeUTF8));
        pushButton_4->setText(QApplication::translate(\"MainWindow\", \"Next\", 0, QApplication::UnicodeUTF8));
        pushButton_5->setText(QApplication::translate(\"MainWindow\", \"Previous\", 0, QApplication::UnicodeUTF8));
        pushButton_6->setText(QApplication::translate(\"MainWindow\", \"First\", 0, QApplication::UnicodeUTF8));
        pushButton->setText(QApplication::translate(\"MainWindow\", \"Save\", 0, QApplication::UnicodeUTF8));
    } // retranslateUi

};

namespace Ui {
    class MainWindow: public Ui_MainWindow {};
} // namespace Ui

QT_END_NAMESPACE

#endif // PROTOTYPEJI3444_H
在多重继承方法中,有一个.h文件及其对应的.cpp文件。我希望有人指导我在哪里建立与sqlite数据库的连接(无论是在.cpp文件中还是在.h文件中)以及如何进行通信我已经显示了使用UI文件显示在Qtableview上来自数据库的数据。 谢谢。     
已邀请:
        实例化QSqlTableModel,使用setModel将其与视图关联,然后将适当的表属性初始化为模型。在init中进行所有操作。     

要回复问题请先登录注册