Results 1 to 2 of 2

Thread: creating new model/view

  1. #1
    Join Date
    Oct 2007
    Location
    Poland
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default creating new model/view

    I would like to display data like this:

    col_1 col_2 col_3
    row_1 |...........|...........|.............|
    row_2 |.....................................|
    row_3 |...........|...........|.............|
    row_4 |...........|...........|.............|
    row_5 |.....................................|
    ....

    With model/view should i use? Is this possible (in general) to display data like this?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: creating new model/view

    You can use QTableView and its QTableView::setSpan(). The model is choice of yours..

    A quick preview of what QTableView is capable of:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5. QApplication app(argc, argv);
    6. QTableWidget table(5, 3);
    7. table.setSpan(1, 0, 1, 3);
    8. table.setSpan(4, 0, 1, 3);
    9. table.show();
    10. return app.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 
    (QTableWidget is a QTableView with built-in model)

    Edit: PS. If you have an existing data structure, I suggest wrapping it to a QAbstractTableModel. Otherwise you may use QStandardItemModel or maybe even QTableWidget as well, depending on your needs.
    Last edited by jpn; 27th October 2007 at 23:35. Reason: updated contents
    J-P Nurmi

Similar Threads

  1. Drag & drop with model/view (Qt4)
    By yogeshm02 in forum Qt Programming
    Replies: 16
    Last Post: 19th September 2011, 20:36
  2. Creating pages
    By hgedek in forum Qt Programming
    Replies: 1
    Last Post: 19th July 2007, 15:11
  3. Using QGraphicsView with model/view programming
    By JLP in forum Qt Programming
    Replies: 3
    Last Post: 29th January 2007, 11:04
  4. Problem in creating thread in GUI application
    By jyoti kumar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2006, 12:05
  5. MODEL/VIEW programming
    By mira in forum Newbie
    Replies: 3
    Last Post: 21st April 2006, 11:19

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.