Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
p, li { white-space: pre-wrap; }
#include <QtGui>
#include <QtSql>
#include "scooterwindow.h"



ScooterWindow::ScooterWindow()

{

    //luodaan malli sql.taululle

    model = new QSqlTableModel(this);

    //lisataan malliin taulu

    model->setTable("tbl_data");

    //laitetaan taulu nimen erusteella laskevaan jarjestykseen

    model->setSort(Scooter_Name, Qt::AscendingOrder);

    //laiteaan sarakkeille  otsikot

    model->setHeaderData(Scooter_Name, Qt::Horizontal, tr("Name"));

    model->setHeaderData(Scooter_Force, Qt::Horizontal, tr("Force"));

    model->setHeaderData(Scooter_Delta, Qt::Horizontal, tr("Delta"));

    model->setHeaderData(Scooter_Time, Qt::Horizontal, tr("Time"));

    model->setHeaderData(Scooter_Description, Qt::Horizontal,

                         tr("Description"));

    //otetaan malli kayttoon

    model->select();

    //tehdaan taululle nakyma

    view = new QTableView;

    //laitetaan malli nakymaan

    view->setModel(model);

    view->setSelectionMode(QAbstractItemView::SingleSelection);

    view->setSelectionBehavior(QAbstractItemView::SelectRows);

    view->setColumnHidden(Scooter_Id, true);

    view->resizeColumnsToContents();

    view->setEditTriggers(QAbstractItemView::NoEditTriggers);



    QHeaderView *header = view->horizontalHeader();

    header->setStretchLastSection(true);

    //tehdaan layout

    QHBoxLayout *mainLayout = new QHBoxLayout;

    //laitetaan layoout paanakymaan

    mainLayout->addWidget(view);

    setLayout(mainLayout);

    //annetaan paaikkunalle nimi

    setWindowTitle(tr("Testi applikaatio"));

}