Re: After resizing Widget with table, table contents not properly displayed
Richard Dale <[email protected]>
| Newsgroups | gmane.comp.kde.devel.perl |
|---|---|
| Organization | Lost Highway |
| Message-ID | <[email protected]> |
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 _______________________________________________ Kde-perl mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-perl
tabletest.cpp
(text/x-c++src, 4.5 KB)
/****************************************************************************
** 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;
}
tabletest.h
(text/x-chdr, 957 B)
/****************************************************************************
** 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