Qt QTableView多重继承方法
Qt QTableView Multiple Inheritance Method
我在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中完成所有操作。
相关文章:
- C++ 多重继承:使用基类 A 的实现实现基类 B 的抽象方法
- 使用父类方法覆盖的多重继承
- C++多重继承 - 相同的方法名称 - 我可以以某种方式删除其中一个吗?
- 通过相同的纯虚拟方法,来自不同抽象基础的C 多重继承
- C 多重继承,虚拟方法覆盖问题和协变量返回类型
- 我应该如何处理类型而不是方法的多重继承冲突
- C++:处理这种多重继承的最佳方法是什么
- 从具有多重继承的派生类调用所有基类的通用命名方法
- 在多重继承布局中单独重写虚拟方法
- 多重继承:2类1方法
- C++从多重继承的模板类中调用虚拟方法
- 虚方法和多重继承
- 在多重继承中,被重写的虚方法保存在c++的虚表中
- c++ - OOP设计-多重继承和纯虚方法
- 为什么多重继承具有不同签名的方法是不明确的
- Qt QTableView多重继承方法
- SWIG JAVA 如何使用 %interface 和纯虚拟方法包装C++多重继承
- 用于多重继承的虚拟方法表
- 处理接口多重继承的方法
- c++多重继承方法重载