Results 1 to 5 of 5

Thread: The tables in the qt creator

  1. #1
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default The tables in the qt creator

    Hello

    I want to create a table by using a qtableView or qtableWidget.

    But how do I put the Header?
    And how to enter data for the table?

    Thank you

  2. #2
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: The tables in the qt creator

    I found this example ===>> http://doc.qt.nokia.com/latest/demos-books.html

    But this exam as a Sql.

    Qt Code:
    1. // Create the data model
    2. model = new QSqlRelationalTableModel(ui.bookTable);
    3. model->setEditStrategy(QSqlTableModel::OnManualSubmit);
    4. model->setTable("books");
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. // Set the localized header captions
    2. model->setHeaderData(authorIdx, Qt::Horizontal, tr("Author Name"));
    3. model->setHeaderData(genreIdx, Qt::Horizontal, tr("Genre"));
    4. model->setHeaderData(model->fieldIndex("title"), Qt::Horizontal, tr("Title"));
    5. model->setHeaderData(model->fieldIndex("year"), Qt::Horizontal, tr("Year"));
    6. model->setHeaderData(model->fieldIndex("rating"), Qt::Horizontal, tr("Rating"));
    To copy to clipboard, switch view to plain text mode 

    What is the solution??!!
    How do I put the Header ?? And how to enter data for the table ??

  3. #3
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: The tables in the qt creator

    No Answers

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: The tables in the qt creator

    There is extensive documentation on Qt's model/view approach to table presentation in the class documentation and in the tutorial and demo programs. Read those before asking such a general question.

    And stop bumping your own posts. Readers are perfectly able to see them all by themselves. You reduce your chances of an answer if you keep shoving them in someone's face.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: The tables in the qt creator

    Start with Model/View Programming. All your answers are there. The Chart Example is very informative.

Similar Threads

  1. Replies: 4
    Last Post: 13th July 2010, 05:17
  2. Replies: 1
    Last Post: 16th May 2010, 19:25
  3. tables
    By tommy in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2007, 15:17
  4. nested tables
    By Jeroen van der Waal in forum Qt Programming
    Replies: 1
    Last Post: 6th June 2007, 17:12

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.