#include "shamelareader.h"
shamelaReader
::shamelaReader(QWidget *parent
){
setCentralWidget(mainText);
db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=c:\\book.mdb");
db.open();
createActions();
createToolBar();
query->exec("SELECT name FROM employee");
query->next();
mainText->setText(query->value(0).toString());
}
void shamelaReader::createActions()
{
nextAct
= new QAction(tr
("&Next"),
this);
connect(nextAct, SIGNAL(triggered()), this, SLOT(next()));
prevAct
= new QAction(tr
("&previous"),
this);
connect(prevAct, SIGNAL(triggered()), this, SLOT(prev()));
firstAct
= new QAction(tr
("first"),
this);
connect(firstAct, SIGNAL(triggered()), this, SLOT(first()));
lastAct
= new QAction(tr
("last"),
this);
connect(lastAct, SIGNAL(triggered()), this, SLOT(last()));
}
void shamelaReader::createToolBar()
{
toolBar = addToolBar(tr("Navigation"));
toolBar->addAction(firstAct);
toolBar->addAction(nextAct);
toolBar->addAction(prevAct);
toolBar->addAction(lastAct);
}
void shamelaReader::next()
{
query->next();
mainText->setText(query->value(0).toString());
}
void shamelaReader::prev()
{
query->previous();
mainText->setText(query->value(0).toString());
}
void shamelaReader::first()
{
query->first();
mainText->setText(query->value(0).toString());
}
void shamelaReader::last()
{
query->last();
if(query->isActive())
if(query->isValid())
mainText->setText(query->value(0).toString());
}
#include "shamelareader.h"
shamelaReader::shamelaReader(QWidget *parent)
: QMainWindow(parent)
{
mainText = new QTextEdit(this);
setCentralWidget(mainText);
db= QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=c:\\book.mdb");
db.open();
createActions();
createToolBar();
query = new QSqlQuery();
query->exec("SELECT name FROM employee");
query->next();
mainText->setText(query->value(0).toString());
}
void shamelaReader::createActions()
{
nextAct = new QAction(tr("&Next"),this);
connect(nextAct, SIGNAL(triggered()), this, SLOT(next()));
prevAct = new QAction(tr("&previous"),this);
connect(prevAct, SIGNAL(triggered()), this, SLOT(prev()));
firstAct = new QAction(tr("first"), this);
connect(firstAct, SIGNAL(triggered()), this, SLOT(first()));
lastAct = new QAction(tr("last"), this);
connect(lastAct, SIGNAL(triggered()), this, SLOT(last()));
}
void shamelaReader::createToolBar()
{
toolBar = addToolBar(tr("Navigation"));
toolBar->addAction(firstAct);
toolBar->addAction(nextAct);
toolBar->addAction(prevAct);
toolBar->addAction(lastAct);
}
void shamelaReader::next()
{
query->next();
mainText->setText(query->value(0).toString());
}
void shamelaReader::prev()
{
query->previous();
mainText->setText(query->value(0).toString());
}
void shamelaReader::first()
{
query->first();
mainText->setText(query->value(0).toString());
}
void shamelaReader::last()
{
query->last();
if(query->isActive())
QMessageBox::warning(this, "title", "Active true");
if(query->isValid())
QMessageBox::warning(this, "title", "true");
mainText->setText(query->value(0).toString());
}
To copy to clipboard, switch view to plain text mode
Bookmarks