PDA

View Full Version : show more lines



Shien
30th May 2011, 15:05
Hi, I am checking this code but I don't understang how to show more lines.


#include "MainWidget.h"

MainWidget::MainWidget(QWidget *parent) :
QWidget(parent)
{
CurrentQueryModel = 0;
//CurrentRecord = 0;
DataSourceConnected = false;
tbvStudentList = new QTableView(this);
dlgUpdate = new StudentUpdateDialog(this);
btnUpdate = new QPushButton("Update", this);
mainLayout = new QGridLayout(this);

connect(btnUpdate, SIGNAL(clicked()), this, SLOT(clickedButtonUpdate()));
connect(this, SIGNAL(clickedUpdate()), dlgUpdate, SLOT(show()));
connect(this, SIGNAL(changedRecord(QSqlRecord)),
dlgUpdate, SLOT(changeRecord(QSqlRecord)));
connect(dlgUpdate, SIGNAL(executeQuery(QString)),
this, SIGNAL(executeUpdate(QString)));

mainLayout->addWidget(tbvStudentList,0, 0, 1, 1);
mainLayout->addWidget(btnUpdate,1, 0, 1, 1);

this->setLayout(mainLayout);
}

void MainWidget::clickedButtonUpdate(void)
{
emit changedRecord(CurrentRecord);

emit clickedUpdate();
//dlgUpdate->show();
}

void MainWidget::connectData(void)
{
//QString tmpQuery = "SELECT ID, Firstname, Surname, BirthDay FROM Student";

DataSourceConnected = true;
//emit executeQuery(tmpQuery);
changeData();
qDebug() << "Emitted signal executeQuery";
}

void MainWidget::processQuery(QSqlQueryModel *parModel)
{
CurrentQueryModel = parModel;
if(CurrentQueryModel == 0) {
qDebug() << "CurrentQueryModel == 0";
} else {
qDebug() << "CurrentQueryModel != 0";
tbvStudentList->setModel(CurrentQueryModel);
CurrentRecord = CurrentQueryModel->record(0);
emit changedRecord(CurrentRecord);
}
}

void MainWidget::changeData(void)
{
QString tmpQuery = "SELECT ID, Firstname, Surname, Birthday FROM Student";

emit executeQuery(tmpQuery);
}

wysota
30th May 2011, 15:12
What lines?

Shien
30th May 2011, 15:16
I am making database GUI I have to show student's group name. but in student table I use only group_id. I hope you understand :D
I don't know how to show it.

wysota
30th May 2011, 15:19
No, I don't understand. I think the code you have shown is completely irrelevant to your problem. Whatever the problem is...

ChrisW67
30th May 2011, 23:22
I don't understand either.


I am making database GUI I have to show student's group name. but in student table I use only group_id.
You are not selecting anything called group_id from the table called Student.

Assuming that you have a Student.group_id column, and you have another table that contains group_id/group_name pairs, and you want to display the group_name then you need to join the two tables either directly in SQL or indirectly in code. If you are intending to edit this view then look at QSqlRelationalTableModel.