winkle99
19th March 2010, 20:59
I am trying to create an in-house, generic open dialog that uses different data models depending on what the user needs to open. I ran into a really weird problem that I'm not sure is me or if there's a bug in Qt. (I'm attaching a simple test case.)
My initial approach was to make the a generic (so that there's no need to subclass from it.) You just set a different model and a few flags and off you go. The problem I ran into is that depending on when I call setResizeMode it does not affect the columns.
My test app puts up a dialog window with a button in it (InitButtonDialog). When the button is clicked a second dialog (DummyDialog) is displayed with a table in it. That table has six columns. The desire is for column 0 to stretch and the others be fixed. The dialog writes, via qDebug() the results of a call to QHeaderView::resizeMode before QHeaderView::setResizeMode is called and after it is called.
If I make the QTableView::setModel call *within* DummyDialog everything works as expected. The resize modes are set and the columns are displayed as desired. ( The qDebug() output reflects this.) HOWEVER, if I make the setModel call fin (InitButtonDialog), the reset modes are not set ( the qDebug() output reflects this as well.)
Has anyone ever seen this?
My initial approach was to make the a generic (so that there's no need to subclass from it.) You just set a different model and a few flags and off you go. The problem I ran into is that depending on when I call setResizeMode it does not affect the columns.
My test app puts up a dialog window with a button in it (InitButtonDialog). When the button is clicked a second dialog (DummyDialog) is displayed with a table in it. That table has six columns. The desire is for column 0 to stretch and the others be fixed. The dialog writes, via qDebug() the results of a call to QHeaderView::resizeMode before QHeaderView::setResizeMode is called and after it is called.
If I make the QTableView::setModel call *within* DummyDialog everything works as expected. The resize modes are set and the columns are displayed as desired. ( The qDebug() output reflects this.) HOWEVER, if I make the setModel call fin (InitButtonDialog), the reset modes are not set ( the qDebug() output reflects this as well.)
Has anyone ever seen this?