Results 1 to 3 of 3

Thread: Span depending on data

  1. #1
    Join Date
    Nov 2016
    Posts
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Span depending on data

    It is necessary to span the cell depending on the data, do it without any problems, but the problems are when used sort column - span is on the same place. I use the following code

    connect(tableView->horizontalHeader(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(slotSetSpan()));

    void tabData::slotSetSpan()
    {
    tableView->clearSpans();
    for (int i = 0; i < tableView->model()->rowCount(); i++){
    int code = tableView->model()->data((tableView->model()->index(i, 2))).toInt();
    if(code == 125) tableView->setSpan(i, 3, 1, tableView->model()->columnCount() - 3);
    }
    }

  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: Span depending on data

    So what is the issue ? Is the code not working ?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Nov 2016
    Posts
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Span depending on data

    Thank you very much! You said that it must work and I found the mistake. It was that in used frozen table (like in Qt examples) the signal disappeared.

Similar Threads

  1. Table View - cell span depends on model data
    By lotek in forum Qt Programming
    Replies: 1
    Last Post: 12th September 2011, 13:09
  2. Replies: 0
    Last Post: 23rd February 2011, 01:07
  3. QTableWidget span !
    By stephanyShulter in forum Newbie
    Replies: 2
    Last Post: 27th October 2008, 15:20
  4. Replies: 1
    Last Post: 16th January 2008, 12:48
  5. QStandarItemModel and span
    By chak_med in forum Qt Programming
    Replies: 1
    Last Post: 4th July 2006, 10:27

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.