Qt-interest Archive, April 2007
Table of Complex Numbers
Message 1 in thread
Dear Group,
I'm new to Qt and evaluating it for a scientific application. I need
your advice.
We want to create a table of Complex numbers, displayed in the format:
Re + jIm, where Re and Im is a doubles. I want both numbers
displayed and editable in a table cell.
Should I be using the QMetaType class to do this job? Will a
"Complex" defined using QMetaType work with the QVariant,
QTableWidget, and QTableWidgetItem classes that come with Qt?
Or is there a better way to approach this design?
Thanks,
Max
--
[ signature omitted ]
Message 2 in thread
On 05.04.07 13:46:41, Max Yaffe wrote:
> Dear Group,
>
> I'm new to Qt and evaluating it for a scientific application. I need
> your advice.
>
> We want to create a table of Complex numbers, displayed in the format:
> Re + jIm, where Re and Im is a doubles. I want both numbers
> displayed and editable in a table cell.
>
> Should I be using the QMetaType class to do this job? Will a
> "Complex" defined using QMetaType work with the QVariant,
> QTableWidget, and QTableWidgetItem classes that come with Qt?
You'd create a Complex class and then use Q_DECLARE_METATYPE(Complex) +
qRegisterMetaType(Complex). That enables wrapping of Complex objects in
a QVariant. As for QTableWidget and QTableWidgetItem you probably need
to use a custom delegate or at least tell each item that it should use
your custom widget for editing.
Andreas
--
[ signature omitted ]