Results 1 to 20 of 20

Thread: Has anyone done dynamic column spanning with a QTableWidget?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2008
    Posts
    183
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Has anyone done dynamic column spanning with a QTableWidget?

    I emailed several others and they conducted their own tests with their own code and got the same results. We didn't share any code. Just be sure to use the tableview with the abstract table model when you conduct your test.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Has anyone done dynamic column spanning with a QTableWidget?

    Quote Originally Posted by RolandHughes View Post
    I emailed several others and they conducted their own tests with their own code and got the same results. We didn't share any code.
    Well, apparently you all got wrong results.

    Qt Code:
    1. #include <QtGui>
    2.  
    3. class Model : public QAbstractTableModel {
    4. public:
    5. Model() {}
    6. int rowCount(const QModelIndex &parent = QModelIndex()) const {
    7. if(parent.isValid()) return 0;
    8. return 1;
    9. }
    10. int columnCount(const QModelIndex &parent = QModelIndex()) const { return 1; }
    11.  
    12. QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const {
    13. Q_UNUSED(index);
    14. if(role != Qt::DisplayRole) return QVariant();
    15. qDebug() << Q_FUNC_INFO;
    16. return "A";
    17. }
    18. };
    19.  
    20. int main(int argc, char **argv) {
    21. QApplication app(argc, argv);
    22. Model model;
    23. QTableView view;
    24. view.setModel(&model);
    25. view.show();
    26. return app.exec();
    27. }
    To copy to clipboard, switch view to plain text mode 

    This test application clearly indicates there is no loop. If you want you can even disrupt the dataChanged() signal connection, modify the model and see that the view doesn't update until something else forces the view to ask explicitly for the item data.

    I do agree though that the default table view and the default delegate read the model data more than one time. This is probably related to auto-sizing columns and rows but this is only my guess.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QTableWidget : dynamic colomn size
    By ArnaudC in forum Qt Programming
    Replies: 0
    Last Post: 11th September 2013, 14:44
  2. Dynamic sorting using proper column after adding a row.
    By kremuwa in forum Qt Programming
    Replies: 1
    Last Post: 28th September 2010, 23:50
  3. Dynamic Sizing of QTableView Column Widths
    By tntcoda in forum Qt Programming
    Replies: 1
    Last Post: 17th June 2009, 18:30
  4. spanning in QTableWidget acting weird
    By ferrari in forum Qt Programming
    Replies: 0
    Last Post: 15th October 2008, 11:31
  5. Replies: 6
    Last Post: 5th March 2006, 21:05

Tags for this Thread

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.