[Kde-perl] After resizing Widget with table, table contents
not properly displayed
Oliver Kreuer
okreuer at PSI.de
Fri Aug 27 13:58:48 CEST 2004
Hello,
thanks for your observation. I translated another example to C++ with
the same result. Every time columns or the whole table are resized there
is some sort of garbage visible in the table.
So I compiled the small table example provided with Qt. And ... surprise
... this example functions correctly. But I can't figure out which
mistakes I make using the QTable API.
Anyway, thanks for your help.
Richard Dale wrote:
> On Saturday 10 July 2004 13:10, Richard Dale wrote:
>
>>On Friday 09 July 2004 09:49, Oliver Kreuer wrote:
>>
>>>I appended two example scripts. The first shows the strange update
>>>behaviour. In the second script I reimplemented method resizeEvent. So
>>>the second one works.
>>>I also tried the Qt::debug qw(virtual) statement but unfortunately the
>>>output doesn't give me a clue.
>>
>>I've been looking at the source in qtable.cpp, and I noticed that QTimers
>>are being used:
>>
>>baldhead duke 1456% grep -i timer qtable.cpp
>>..
>> widgetStretchTimer->stop();
>> stretchTimer->start( 0, TRUE );
>> widgetStretchTimer->start( 100, TRUE );
>> autoScrollTimer->start( 100, TRUE );
>>
>>So it looks to me that the problem is that perlqt and qtruby are too slow
>>to get something done in 100ms, and the timer times out before anything is
>>drawn. Everytime a virtual method is called the PerlQt runtime checks to
>>see whether on not you have overriden the method in your perl code:
>>
>> const char *methodName = smoke->methodNames[smoke->methods[method].name];
>> GV *gv = gv_fetchmethod_autoload(stash, methodName, 0);
>> if(!gv) return false;
>>
>>The only way I can think to speed this up is to have some sort of 'virtual
>>method callbacks' cache which was only updated when you created a new
>>instance of your perl object.
>
> I tried increasing the timeout interval to 1 second, and that had no effect.
> Then I commented out the code above that looks for the perl method via
> autoload, and just made it always return false. Apart from stopping signals
> and slots working, so I had to call tableTwoRows() directly, that didn't have
> any effect.
>
> I just couldn't see what the problem was, so I translated the example to C++.
> Guess what? I doesn't work either! So it does look like some sort of Qt bug,
> or maybe the code is using the QTable api wrongly in some way.
>
> -- Richard
>
>
> ------------------------------------------------------------------------
>
> /****************************************************************************
> ** Form implementation generated from reading ui file 'tabletest.ui'
> **
> ** Created: Sun Jul 11 10:01:57 2004
> ** by: The User Interface Compiler ($Id: qt/main.cpp 3.1.1 edited Nov 21 17:40 $)
> **
> ** WARNING! All changes made in this file will be lost!
> ****************************************************************************/
>
> #include "tabletest.h"
>
> #include <qvariant.h>
> #include <qpushbutton.h>
> #include <qtable.h>
> #include <qlayout.h>
> #include <qtooltip.h>
> #include <qwhatsthis.h>
> #include <qimage.h>
> #include <qpixmap.h>
> #include <qapplication.h>
>
> /*
> * Constructs a TableExample as a child of 'parent', with the
> * name 'name' and widget flags set to 'f'.
> */
> TableExample::TableExample( QWidget* parent, const char* name, WFlags fl )
> : QWidget( parent, name, fl )
> {
> if ( !name )
> setName( "TableExample" );
>
> QGridLayout * table_exampleLayout = new QGridLayout(this, 1, 1, 11, 6, "$table_exampleLayout");
>
> QFrame * frame6 = new QFrame(this, "frame6");
> frame6->setFrameShape( QFrame::StyledPanel);
> frame6->setFrameShadow( QFrame::Raised );
> QGridLayout * frame6Layout = new QGridLayout(frame6, 1, 1, 11, 6, "$frame6Layout");
> QSpacerItem * spacer = new QSpacerItem(190, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
> frame6Layout->addItem(spacer, 1, 3);
>
> One_Row = new QPushButton( frame6, "One_Row" );
> frame6Layout->addWidget(One_Row, 1, 1);
>
> table = new QTable( this, "table1" );
> table->setNumRows( 8 );
> table->setNumCols( 2 );
> table->setReadOnly( true );
> table->setSelectionMode( QTable::NoSelection );
> table->setLeftMargin(0); // don't show left vertical header
>
> frame6Layout->addMultiCellWidget(table, 0, 0, 0, 3);
>
> Two_Rows = new QPushButton( frame6, "Two_Rows" );
>
> frame6Layout->addWidget(Two_Rows, 1, 2);
> QSpacerItem * spacer_2 = new QSpacerItem(190, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
> frame6Layout->addItem(spacer_2, 1, 0);
>
> table_exampleLayout->addWidget(frame6, 0, 0);
>
> languageChange();
>
> QSize res(586, 482);
> res.expandedTo(minimumSizeHint());
> resize( res );
> clearWState( WState_Polished );
>
> QObject::connect(One_Row, SIGNAL(clicked()), this, SLOT(tableOneRow()));
> QObject::connect(Two_Rows, SIGNAL(clicked()), this, SLOT(tableTwoRows()));
> }
>
> /*
> * Destroys the object and frees any allocated resources
> */
> TableExample::~TableExample()
> {
> // no need to delete child widgets, Qt does it all for us
> }
>
> void
> TableExample::tableOneRow()
> {
> }
>
> void
> TableExample::tableTwoRows()
> {
> table->setNumCols(2);
> table->horizontalHeader()->setStretchEnabled(true);
> table->horizontalHeader()->setLabel(0,"Erste Spalte",-1);
> table->horizontalHeader()->setLabel(1,"Zweite Spalte",-1);
> table->horizontalHeader()->setClickEnabled(0,-1);
> table->setNumRows(8);
> table->setFocusPolicy( QTable::NoFocus );
>
> table->setItem(0,0,new QTableItem(table,QTableItem::Never,"One"));
> table->setItem(0,1,new QTableItem(table,QTableItem::Never,""));
>
> table->setItem(1,0,new QTableItem(table,QTableItem::Never,"Two"));
> table->setItem(1,1,new QTableItem(table,QTableItem::Never,""));
>
> table->setItem(2,0,new QTableItem(table,QTableItem::Never,"Three"));
> table->setItem(2,1,new QTableItem(table,QTableItem::Never,""));
>
> table->setItem(3,0,new QTableItem(table,QTableItem::Never,"Four"));
> table->setItem(3,1,new QTableItem(table,QTableItem::Never,""));
>
> table->setItem(4,0,new QTableItem(table,QTableItem::Never,"1_1"));
> table->setItem(4,1,new QTableItem(table,QTableItem::Never,"1_2"));
>
> table->setItem(5,0,new QTableItem(table,QTableItem::Never,"2_1"));
> table->setItem(5,1,new QTableItem(table,QTableItem::Never,"2_2"));
>
> table->setItem(6,0,new QTableItem(table,QTableItem::Never,"3_1"));
> table->setItem(6,1,new QTableItem(table,QTableItem::Never,"3_2"));
>
> table->setItem(7,0,new QTableItem(table,QTableItem::Never,"4_1"));
> table->setItem(7,1,new QTableItem(table,QTableItem::Never,"4_2"));
> }
>
> /*
> * Sets the strings of the subwidgets using the current
> * language.
> */
> void TableExample::languageChange()
> {
> setCaption( tr( "TableExample" ) );
> One_Row->setText( trUtf8("One Row") );
> Two_Rows->setText( trUtf8("Two Rows") );
> }
>
> int main(int argc, char * argv[]) {
> QApplication app(argc, argv);
> TableExample * w = new TableExample();
> app.setMainWidget(w);
> w->show();
> app.exec();
> return 0;
> }
>
>
>
> ------------------------------------------------------------------------
>
> /****************************************************************************
> ** Form interface generated from reading ui file 'tabletest.ui'
> **
> ** Created: Sun Jul 11 09:24:21 2004
> ** by: The User Interface Compiler ($Id: qt/main.cpp 3.1.1 edited Nov 21 17:40 $)
> **
> ** WARNING! All changes made in this file will be lost!
> ****************************************************************************/
>
> #ifndef FORM1_H
> #define FORM1_H
>
> #include <qvariant.h>
> #include <qwidget.h>
>
> class QVBoxLayout;
> class QHBoxLayout;
> class QGridLayout;
> class QPushButton;
> class QTable;
>
> class TableExample : public QWidget
> {
> Q_OBJECT
>
> public:
> TableExample( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
> ~TableExample();
>
> QPushButton* One_Row;
> QPushButton* Two_Rows;
> QTable* table;
>
> public slots:
> void tableOneRow();
> void tableTwoRows();
>
>
> protected:
>
> protected slots:
> virtual void languageChange();
> };
>
> #endif // FORM1_H
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Kde-perl mailing list
> Kde-perl at kde.org
> https://mail.kde.org/mailman/listinfo/kde-perl
--
Oliver Kreuer
PSI AG
Bernsaustrasse 4-6
42553 Velbert (Neviges)
Telefon +49/2053/919-211
Telefax +49/2053/919-194
E-Mail okreuer at psi.de
More information about the Kde-perl
mailing list