Results 1 to 3 of 3

Thread: How to use setSpan in QTableView

  1. #1
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    1
    Qt products
    Platforms
    MacOS X Windows

    Question How to use setSpan in QTableView

    Hi,

    I'm using a QTableView with a QAbastractTableModel. In some rows in the table, all columns should be merged into one cell, according to the model data. I'm confused that setSpan is a function of the viewer class, not the model class. Then how should I use setSpan to achieve my goal?

    I tried to subclass QTableView and modify setModel function. Call setSpan inside setModel, didn't work....

    Thanks!

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: How to use setSpan in QTableView

    It should be simple, you could do this with out custom view, just set the cell span

    Qt Code:
    1. view.setModel(model);
    2. view.setSpan(0, 0, 1, model->columnCount()); //sets the 1st row 1st column cell to span over all the columns
    3. view.show();
    To copy to clipboard, switch view to plain text mode 

  3. The following 2 users say thank you to Santosh Reddy for this useful post:

    3str (3rd August 2011), amel (25th September 2012)

  4. #3
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    1
    Qt products
    Platforms
    MacOS X Windows

    Default Re: How to use setSpan in QTableView

    Thanks. This is very straightforward. I was expecting some trick that the Model/View framework could handle this automatically.

Similar Threads

  1. QTableView and QLineEdit OUTSIDE of QTableView, like Excel
    By JoZCaVaLLo in forum Qt Programming
    Replies: 10
    Last Post: 13th May 2011, 13:20
  2. Replies: 2
    Last Post: 26th November 2009, 04:45
  3. QTableWidget setSpan text display problem
    By sureshbabu in forum Qt Programming
    Replies: 3
    Last Post: 8th May 2008, 16:14
  4. QTableWidget and setSpan
    By swiety in forum Qt Programming
    Replies: 1
    Last Post: 17th October 2007, 10:47
  5. QTableView - Add Row
    By maxpower in forum Qt Programming
    Replies: 1
    Last Post: 24th November 2006, 18:18

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.