PDA

View Full Version : Qtablewidget like Excel



advseo32
9th August 2013, 20:28
Hi every body ,


i want to reimplement my QtableWidget to work like so,

at start QtableWidget looks like so

________________________
|column1| column2| column3|
--------|--------|-------- |
|x |y |z=x*y |
-----------------------------

I want this :

when user type a number in Column1(X) and Column2 (Y) ( user must fill x and y to be able to show result in z)

the result updated automatically in Column3 (Z)

how i can do this ???

advseo32
10th August 2013, 08:38
plz i need a hint

advseo32
10th August 2013, 18:35
if my post is not clera

i need some thing like so,

////////////////////////////////
// combobox //
//////////////////////////////////////////////////////////////////////////////////
// Qtableview her with all cells inside it ** Horizontal Header //
/////////////////////////////////////////////////////////////////////////////////
/// row 0 //
/////////////////////////////////////////////////////////////////////////////////
/// row 1 //
/////////////////////////////////////////////////////////////////////////////////
/// row 2 //
/////////////////////////////////////////////////////////////////////////////////

Lykurg
10th August 2013, 18:52
Use QTableWidget::cellChanged(). Connect it to a slot, calculate and update the result.

advseo32
10th August 2013, 22:21
thanks a lot

is this the optimized methode ??

you have an idea about how MS excel calculate results ?

Lykurg
11th August 2013, 10:04
is this the optimized methode ??
Yes, I think so.


you have an idea about how MS excel calculate results ?
Well, it does not use Qt, but the general approach is the same: detect value change, recalculate, update with new value (if needed). How could one optimize that?

advseo32
11th August 2013, 13:45
Yes, I think so.


Well, it does not use Qt, but the general approach is the same: detect value change, recalculate, update with new value (if needed). How could one optimize that?

don't worry about this , i want only to get advices from professionals, and correct my errors :)

thank's for helping

ChrisW67
13th August 2013, 02:36
I imagine that Excel creates a dependency tree between cells in much the same way that make does for builds. When a cell is changed the downstream recalculation flows by simply following the dependency tree. This approach allows for early detection of circular references.

C++ GUI Programming with Qt 4 (Second Edition) walks through a simple spreadsheet application. The same example may be in the first edition (which can be had for no money). http://www.qtrac.eu/marksummerfield.html