Results 1 to 7 of 7

Thread: Resizing QSqlTableModel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jan 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Resizing QSqlTableModel

    Thanks, but I don't realy know how to use it.

    I'm creating my QTableView in function Okno::baza() :

    Qt Code:
    1. db = QSqlDatabase::addDatabase("QSQLITE");
    2. db.setDatabaseName("magazyn");
    3. db.open();
    4. tabelka = new QSqlTableModel;
    5. tabelka->setTable("produkty");
    6. tabelka->select();
    7. tabelka->setHeaderData(0, Qt::Horizontal, tr("Id"));
    8. tabelka->setHeaderData(1, Qt::Horizontal, tr("Nazwa"));
    9. tabelka->setHeaderData(2, Qt::Horizontal, tr("Ilość"));
    10. tabelka->setHeaderData(3, Qt::Horizontal, tr("Cena Netto"));
    11. tabelka->setHeaderData(4, Qt::Horizontal, tr("Data Ważności"));
    12. view = new QTableView;
    13. view->setModel(tabelka);
    To copy to clipboard, switch view to plain text mode 

    In constructor Okno::Okno() I'm adding view do layout:

    Qt Code:
    1. baza();
    2. centralWidget = new QWidget;
    3. glowny = new QVBoxLayout;
    4. glowny->addWidget(view, 0, Qt::AlignHCenter);
    5. centralWidget->setLayout(glowny);
    6. setCentralWidget(centralWidget);
    To copy to clipboard, switch view to plain text mode 

    Class Okno inherits from QMainWindow.
    Last edited by teS; 12th January 2006 at 22:00.

Similar Threads

  1. QSqlTableModel inserts empty rows
    By Nesbitt in forum Qt Programming
    Replies: 2
    Last Post: 6th August 2008, 12:47
  2. Replies: 4
    Last Post: 9th May 2008, 17:02
  3. Replies: 2
    Last Post: 14th August 2007, 15:16
  4. QMdiSubWindow resizing in 4.3
    By kalpa in forum Qt Programming
    Replies: 0
    Last Post: 4th June 2007, 13:39
  5. QSqlTableModel cannot change values
    By raphaelf in forum Newbie
    Replies: 2
    Last Post: 23rd May 2007, 08:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.