Qt-interest Archive, August 2006
QTable and setCell
Message 1 in thread
Dear list,
I have A QTable with 34 columns of which 2 columns contain QWidgets (added with
setCellWidget) and the other cells contain QTableItems.
When adding more than about 180 rowsto this table the program looks like it goes
into an infinite redraw loop. A number of QWidgests seem to be positioned
outside the QTable (actually they are at the top left corner of my screen).
Has anybody seen this behaviour before ?
Are there any limitations to the number of QWidgets that can be added to a QTable ?
I'm workinging wit Qt 3.3.3
Any suggestion is welcome.
regards,
--
[ signature omitted ]
Message 2 in thread
Tom,
Thank you for your answer.
I have created the rows and columns, otherwise one gets a message about the
insertion.
Regards,
Albert
Tom Marrion wrote:
> On Thu, 2006-08-03 at 20:40 +0200, Albert van der Meer wrote:
>
>>Dear list,
>>
>>I have A QTable with 34 columns of which 2 columns contain QWidgets (added with
>>setCellWidget) and the other cells contain QTableItems.
>>When adding more than about 180 rowsto this table the program looks like it goes
>>into an infinite redraw loop. A number of QWidgests seem to be positioned
>>outside the QTable (actually they are at the top left corner of my screen).
>>
>>Has anybody seen this behaviour before ?
>>Are there any limitations to the number of QWidgets that can be added to a QTable ?
>>
>>I'm workinging wit Qt 3.3.3
>>
>
> You probably haven't created the row or column before setting the cell
> widget
>
> Tom Marrion
>
--
[ signature omitted ]
Message 3 in thread
Hi Albert,
something similar happened to me when I inserted about 2000 rows, but in
my case I were using only QTableItems (just text). Then one and only
solution I found were using setUpdatesEnabled to avoid that ugly
repaint. I set the updates off before inserting, and on after all the
stuff, then call repaint.
Hope this helps you in some way.
Javier.
Albert van der Meer escribió:
> Tom,
>
> Thank you for your answer.
> I have created the rows and columns, otherwise one gets a message
> about the insertion.
>
> Regards,
>
> Albert
>
> Tom Marrion wrote:
>
>> On Thu, 2006-08-03 at 20:40 +0200, Albert van der Meer wrote:
>>
>>> Dear list,
>>>
>>> I have A QTable with 34 columns of which 2 columns contain QWidgets
>>> (added with setCellWidget) and the other cells contain QTableItems.
>>> When adding more than about 180 rowsto this table the program looks
>>> like it goes into an infinite redraw loop. A number of QWidgests
>>> seem to be positioned outside the QTable (actually they are at the
>>> top left corner of my screen).
>>>
>>> Has anybody seen this behaviour before ?
>>> Are there any limitations to the number of QWidgets that can be
>>> added to a QTable ?
>>>
>>> I'm workinging wit Qt 3.3.3
>>>
>>
>> You probably haven't created the row or column before setting the cell
>> widget
>>
>> Tom Marrion
>>
>
--
[ signature omitted ]
Message 4 in thread
Javier,
Thank you for the suggestion, unfortunately it did not work.
Currently I'm working on reducing the program. When I have a minimal set I will
post it.
For information to you all: I'm Using Windows 200 with MSVC 6
regards,
Albert
Javier Díaz wrote:
> Hi Albert,
>
> something similar happened to me when I inserted about 2000 rows, but in
> my case I were using only QTableItems (just text). Then one and only
> solution I found were using setUpdatesEnabled to avoid that ugly
> repaint. I set the updates off before inserting, and on after all the
> stuff, then call repaint.
>
> Hope this helps you in some way.
>
> Javier.
>
> Albert van der Meer escribió:
>
>> Tom,
>>
>> Thank you for your answer.
>> I have created the rows and columns, otherwise one gets a message
>> about the insertion.
>>
>> Regards,
>>
>> Albert
>>
>> Tom Marrion wrote:
>>
>>> On Thu, 2006-08-03 at 20:40 +0200, Albert van der Meer wrote:
>>>
>>>> Dear list,
>>>>
>>>> I have A QTable with 34 columns of which 2 columns contain QWidgets
>>>> (added with setCellWidget) and the other cells contain QTableItems.
>>>> When adding more than about 180 rowsto this table the program looks
>>>> like it goes into an infinite redraw loop. A number of QWidgests
>>>> seem to be positioned outside the QTable (actually they are at the
>>>> top left corner of my screen).
>>>>
>>>> Has anybody seen this behaviour before ?
>>>> Are there any limitations to the number of QWidgets that can be
>>>> added to a QTable ?
>>>>
>>>> I'm workinging wit Qt 3.3.3
>>>>
>>>
>>> You probably haven't created the row or column before setting the cell
>>> widget
>>>
>>> Tom Marrion
>>>
>>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
--
[ signature omitted ]
Message 5 in thread
Dear group,
As promissed I have tried to create a small program that shows my problem.
I have included the source files.
You can run the program by starting it and than giving a <return> in the
line edit window of the "TCL Command" window (the focus should alread be there).
The problem is that I get some parts of the windows in the top left hand
corner of my screen and furthermore I get a number of windows with the
name "unnamed" and "materials" in my task bar.
When moving my mouse or set the focus to another window I get a lot of
flicker and it looks like the program goes into an infinite loop (not always).
In case the problem does not occur please increase the value of 1000 in the
file Connectionwindow.cpp.
To see the intentions of the "extended connection window" set the number 1000
to 5 in the file Connectionwindow.cpp.
I'm using Qt 3.3.3 on a windows 2000 system with the MSVC 6.0 compiler.
Regards,
Albert
--
[ signature omitted ]
#ifndef APPLICATION_H
#define APPLICATION_H
#include <qmainwindow.h>
#include <qthread.h>
#include <qptrlist.h>
#include <qsettings.h>
class QWorkspace;
class TclWindow;
class ConnectionWindow;
class ApplicationWindow;
class ApplicationWindow: public QMainWindow
{
Q_OBJECT
public:
ApplicationWindow();
~ApplicationWindow()
{}
void updatePulApp();
TclWindow* TCLWindow;
ConnectionWindow* XTableWindow;
private:
QWorkspace* ws;
};
#endif
#include <iostream.h>
#include <iostream.h>
#include "ConnectionWindow.h"
#include "rttiPulsim.h"
#include <qtable.h>
#include <qtabwidget.h>
#include <qlayout.h>
#define MARGINS 0
ConnectionWindow::ConnectionWindow(QWidget* parent, const char* name, int wflags): QMainWindow(parent, name, wflags)
{
QString strName = "PI";
setName("ExtendedConnectionWindow");
setCaption(trUtf8("Extended Connections Window"));
setCentralWidget(new QWidget(this, "qt_central_widget"));
WindowLayout = new QHBoxLayout(centralWidget(), MARGINS, MARGINS, "Form4");
WindowLayout->setMargin(MARGINS);
TabWidget4 = new QTabWidget(centralWidget(), "TabWidget4");
QWidget* tab_2 = new QWidget(TabWidget4, strName);
QHBoxLayout* tabLayout_2 = new QHBoxLayout(tab_2, MARGINS, MARGINS, "tabLayout_2");
QVBoxLayout* Layout17 = new QVBoxLayout(0, MARGINS, MARGINS, "Layout17");
QString TableName = "Table" + strName;
QTable *ConnTable = new QTable(tab_2, TableName);
ConnTable->setNumRows(0);
ConnTable->setNumCols(1);
ConnTable->setLeftMargin(0);
ConnTable->setShowGrid(false);
ConnTable->verticalHeader()->hide();
ConnTable->horizontalHeader()->setLabel(0, "Column 1");
Layout17->addWidget((QWidget*)ConnTable);
tabLayout_2->addLayout(Layout17);
TabWidget4->insertTab(tab_2, trUtf8(strName));
WindowLayout->addWidget(TabWidget4);
}
void ConnectionWindow::updatePulsim()
{
int ii;
int kk;
int nrRows = 1000;
QString Name = "TablePI";
QObject* Tab = TabWidget4->child(Name, 0, true);
((QTable*)Tab)->setNumRows(nrRows);
for (ii=0; ii < nrRows; ii++)
{
cout << "ii = " << ii << "\r" << flush;
QWidget *item = rttiWidget((QTable*)Tab);
((QTable*)Tab) -> setCellWidget(ii, 0, item);
}
cout << ("\n");
cout << "loop done\n";
for (kk=0; kk < ((QTable*)Tab)->numCols(); kk++)
{
((QTable*)Tab)->adjustColumn(kk);
}
cout << "Done\n" << flush;
}
#ifndef CONNECTIONWINDOW_H
#ifndef CONNECTIONWINDOW_H
#define CONNECTIONWINDOW_H
#include <qmainwindow.h>
#include <qtabwidget.h>
#include <qtable.h>
#include "rttiPulsim.h"
class ConnectionWindow: public QMainWindow, public rttiPulsim
{
Q_OBJECT
public:
ConnectionWindow(QWidget* parent, const char* name, int wflags);
~ConnectionWindow()
{}
QTabWidget* TabWidget4;
QWidget* tab_2;
protected:
QHBoxLayout* WindowLayout;
QVBoxLayout* tabLayout;
QVBoxLayout* tabLayout_2;
QVBoxLayout* Layout17;
public slots:
void updatePulsim();
};
#endif
#include <qapplication.h>
#include <qapplication.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <qdialog.h>
#include <qrect.h>
#include <qpushbutton.h>
#include <qcursor.h>
#include "application.h"
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
ApplicationWindow * mw = new ApplicationWindow();
mw->show();
a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) );
QApplication::restoreOverrideCursor();
int res = a.exec();
delete mw;
return res;
}
#include <qlayout.h>
#include <qlayout.h>
#include "pulsimGroupBox.h"
#include "rttiPulsim.h"
pulsimGroupBox::pulsimGroupBox(QWidget *parent, const QString name, int rows, int cols)
: QGroupBox(parent,name),rttiPulsim(),nrrows(rows), nrcols(cols)
{
setColumnLayout(0, Qt::Vertical);
setInsideMargin(4);
setFlat(TRUE);
widgets = new QWidget** [rows];
for (int i = 0; i < rows; i++)
{
widgets[i] = new QWidget* [cols];
for (int j = 0; j < cols; j++)
{
widgets[i][j] = NULL;
}
}
}
void pulsimGroupBox::displayPulsimGroupBox()
{
gbl = new QGridLayout(layout(), nrrows, nrcols);
gbl->setAlignment(Qt::AlignTop);
gbl->setSpacing(2);
for (int i = 0; i < nrrows; i++)
{
for (int j = 0; j < nrcols; j++)
{
if (widgets[i][j] != NULL)
{
gbl->addWidget(widgets[i][j],i,j);
}
}
}
}
#include "qtable.h"
#include "qtable.h"
#include "qgroupbox.h"
#include "rttiPulsim.h"
class pulsimGroupBox: public QGroupBox, public rttiPulsim
{
Q_OBJECT
public:
pulsimGroupBox(QWidget *widget, const QString name, int rows, int cols);
~pulsimGroupBox()
{}
void displayPulsimGroupBox();
QWidget ***widgets;
private:
QGridLayout *gbl;
int nrcols;
int nrrows;
};
#include <qlabel.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qbuttongroup.h>
#include <qradiobutton.h>
#include <qcombobox.h>
#include "rttiPulsim.h"
#include "pulsimGroupBox.h"
#define ROWS 1
#define DATA_ROW 0
#define COLS 12
#define STD_RB 0
#define UD_RB 1
#define NAME_COL 2
#define NAMEU_COL 3
#define POIS_COL 4
#define POISU_COL 5
#define RHO_COL 6
#define RHOU_COL 7
#define EXP_COL 8
#define EXPU_COL 9
#define ELM_COL 10
#define ELMU_COL 11
QWidget * rttiPulsim::rttiWidget(QWidget *parent)
{
pulsimGroupBox *qw;
QRadioButton *rb1;
QRadioButton *rb2;
QStringList combo;
combo << "Value 1";
combo << "Value 2";
qw = new pulsimGroupBox(parent, "PulsimGroupBox", ROWS, COLS);
QButtonGroup *radioButtons = new QButtonGroup(qw);
radioButtons->setExclusive(true);
radioButtons->hide();
rb1 = new QRadioButton(qw);
qw -> widgets[DATA_ROW][STD_RB] = rb1;
radioButtons -> insert(rb1);
rb2 = new QRadioButton(qw);
qw -> widgets[DATA_ROW][UD_RB] = rb2;
radioButtons -> insert(rb2);
qw -> widgets[DATA_ROW][NAME_COL] = new QComboBox(qw, "materials");
((QComboBox *)(qw -> widgets[DATA_ROW][NAME_COL])) -> insertStringList(combo);
qw -> widgets[DATA_ROW][POIS_COL] = new QLineEdit(qw);
qw -> widgets[DATA_ROW][POISU_COL] = new QLabel("[-]", qw);
qw -> widgets[DATA_ROW][RHO_COL] = new QLineEdit(qw);
qw -> widgets[DATA_ROW][RHOU_COL] = new QLabel("[kg/m3]", qw);
qw -> widgets[DATA_ROW][EXP_COL] = new QLineEdit(qw);
qw -> widgets[DATA_ROW][EXPU_COL] = new QLabel("[m/mC]", qw);
qw -> widgets[DATA_ROW][ELM_COL] = new QLineEdit(qw);
qw -> widgets[DATA_ROW][ELMU_COL] = new QLabel("[N/m2]", qw);
qw -> displayPulsimGroupBox();
return (qw);
}
#ifndef RTTIPULSIM_H
#ifndef RTTIPULSIM_H
#define RTTIPULSIM_H
#include <qwidget.h>
class rttiPulsim
{
public:
rttiPulsim()
{}
~rttiPulsim()
{}
QWidget *rttiWidget(QWidget *widget);
};
#endif
#include "TclLineEdit.h"
#include "TclLineEdit.h"
void TclLineEdit::keyPressEvent(QKeyEvent * qke)
{
if (qke->key() == Key_Return)
{
qke->accept();
reinterpret_cast<TclWindow*>(parent()->parent())->ExecuteCmdLow();
}
}
#ifndef TCLLINEEDIT_H
#ifndef TCLLINEEDIT_H
#define TCLLINEEDIT_H
#include <qlineedit.h>
#include <qwaitcondition.h>
#include "TclWindow.h"
class TclLineEdit: public QLineEdit
{
public:
TclLineEdit(QWidget *parent, const char *name = 0):QLineEdit(parent, name)
{}
~TclLineEdit()
{}
void keyPressEvent(QKeyEvent * qke);
};
#endif
#include <qapplication.h>
#include <qapplication.h>
#include <qmainwindow.h>
#include <qaccel.h>
#include <qdatetime.h>
#include <qcursor.h>
#include <math.h>
#include "TclWindow.h"
#include "TclLineEdit.h"
#include "rttiPulsim.h"
TclWindow::TclWindow(QWidget* parent, const char* name, int wflags, ApplicationWindow *app)
: QMainWindow(parent, name, wflags)
{
if (!name) setName("TCLCommand");
instance = app;
setCaption(trUtf8("TCL Command"));
setCentralWidget(new QWidget(this, "qt_central_widget"));
box = new QVBoxLayout(centralWidget(), 0, 0, "Form4Layout");
TextEditOutput = new QTextEdit(centralWidget() , "TextEditOutput");
TextEditOutput->setGeometry(QRect(10, 10, 600, 210));
QFont TextEditOutput_font(TextEditOutput->font());
TextEditOutput_font.setFamily("Courier New");
TextEditOutput->setFont(TextEditOutput_font);
TextEditOutput->setVScrollBarMode(QTextEdit::AlwaysOn);
TextEditOutput->setTextFormat(QTextEdit::PlainText);
TextEditOutput->setText(trUtf8(""));
TextEditOutput->setReadOnly(TRUE);
TextEditOutput->setOverwriteMode(TRUE);
TextEditOutput->setWordWrap(QTextEdit::NoWrap);
box->addWidget(TextEditOutput);
box->setMargin(0);
TextEditOutput->insert("Welcome\n");
TextEditOutput->insert("To start the process see to it that the line edit\n");
TextEditOutput->insert("below is active\n");
TextEditOutput->insert("\n");
TextEditOutput->insert("Hit the <return> key\n");
TextEditOutput->insert("and watch the problem occur\n");
edt = new TclLineEdit(centralWidget(), 0);
edt->setGeometry(10, 230, 600, 20);
QFont LineEdit_font(edt->font());
LineEdit_font.setFamily("Courier New");
edt->setFocus();
box->addWidget(edt);
}
void TclWindow::ExecuteCmdLow()
{
instance -> updatePulApp();
edt -> setEnabled(true);
}
#ifndef TCLWINDOW_H
#ifndef TCLWINDOW_H
#define TCLWINDOW_H
#include <qmainwindow.h>
#include <qtextedit.h>
#include <qlayout.h>
#include "application.h"
class TclLineEdit;
class TclWindow: public QMainWindow
{
Q_OBJECT
public:
TclWindow(QWidget* parent, const char* name, int wflags,
ApplicationWindow *app);
~TclWindow()
{}
QTextEdit *TextEditOutput;
TclLineEdit *edt;
ApplicationWindow *instance;
void ExecuteCmdLow();
private:
QVBoxLayout *box;
};
#endif