Trolltech Home | Qt-jambi-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-jambi-interest Archive, June 2007
Problems with QTableView


Message 1 in thread

Hi folks,

I'm having an issue with QTableView since Qt Jambi 0.1. It looks like 
QTableView isn't updated as expected although this worked in QtJambi 
0.1_beta2. My testcase builds up a simple table with an also simple 
QAbstractTableModel. This model will return 0 columns and rows for the 
first two seconds the program runs, then layoutChanged is emited and 
columnCount gets 4 and rowCount gets 15. This thing works flawlessly 
with beta2 but the table remains empty with 0.1_final. Firing other 
signals like dataChanged or headerChanged doesn't help, still empty. So 
which signal should be emitted when the modeldata updates?

My testcase can be found here: 
http://crosswidgets.sourceforge.net/QtTest.java

I found out that there's a difference in methodcalls between beta2 and 
final by printing the stack trace of an Exception ( if (done) new 
Exception().printStackTrace(); ) in check(). It seems that beta2 queries 
all methods from the model whereas final only queries columnCount() and 
nothing else.

More Details: I previously used Qt Jambi 0.1_beta2 32bit for Linux, now 
I use the 64bit version of 0.1_final.



Best regards

Georg Schild


Message 2 in thread

Hi,

I had the same problem when I switched from Beta 2 to the final release.
Just call reset() instead of layoutChanged() and it should work again.


Regards,

Andreas


Message 3 in thread

Hi,

Andreas Heck schrieb:
> I had the same problem when I switched from Beta 2 to the final release.
> Just call reset() instead of layoutChanged() and it should work again.

thank you, that function did it. I didn't search for some function from 
the model which does the update, I thought it would either be a signal 
in the model or an update-function of the QTableView.


Best regards

Georg Schild


Message 4 in thread

Georg Schild wrote:
> Hi folks,
> 
> I'm having an issue with QTableView since Qt Jambi 0.1. It looks like 
> QTableView isn't updated as expected although this worked in QtJambi 
> 0.1_beta2. My testcase builds up a simple table with an also simple 
> QAbstractTableModel. This model will return 0 columns and rows for the 
> first two seconds the program runs, then layoutChanged is emited and 
> columnCount gets 4 and rowCount gets 15. This thing works flawlessly 
> with beta2 but the table remains empty with 0.1_final. Firing other 
> signals like dataChanged or headerChanged doesn't help, still empty. So 
> which signal should be emitted when the modeldata updates?

You should not emit these signals yourself. They should be emitted by 
the QAbstractItemModel when you explicitly tell it that you have added 
rows and colums. This is done using the functions beginInsertRows() and 
beginInsertColumns(). Between begin() and end() you update your 
datastructure so that rowCount() and columnCount() returns the right 
values for the new layout.

         private void check() {
             System.out.println("checking " + done + "  " + first);
             if (System.currentTimeMillis()-2000 >= oldTime) {
                 done = true;
                 if (!first) {
                     first = true;
                     beginInsertRows(null, 0, 15);
                     beginInsertColumns(null, 0, 4);
                     // update datastructure...
                     endInsertRows();
                     endInsertColumns();
                 }
             }
         }

best regards,
Gunnar