The sum() action of the spreadsheet app faces problems
-
@tomy said in The sum() action of the spreadsheet app faces problems:
int i, j;
double d;You do not set a initial value. (zero)
So when you do
d += item->text().toDouble();it might count funny/randomly.
-
int i, j;
double d;You do not set a initial value. (zero)
So when you do
d += item->text().toDouble();it might count funny/randomly.
I'd previously set them to zero but you asked me these questions:
What happens if you select nothing and then add sum ?
Will it not insert 0 anyway ?
Is that how you want it?To be honest, through the C++ book, I've been taught that never leave a variable alone without initializing.
I modified the code this way:
bool b = false; if(!items.isEmpty()) { foreach (QTableWidgetItem* item, items) d += item->text().toDouble(); b = true; } ... if(b) QTableWidget::setItem(i, j, item);
Agree?
-
Why you dont use QtXlsxWriter ... this tool calculate read write excel inside all box ... e sum in easy way... this module must take a oscar...
-
Hi,
What about using the debugger to get a stack trace ?
Also, did you check the value of
I
? -
One question on graphic visage of the app.
Please take a look:To me, it looks like a Win 2000 app and old fashioned! People expect more graphical and splendid apps nowadays.
I think we can make such new-fashioned apps using Qt, can't we?!I toyed with that and changed two lines of code from
Qt_4_3
toQt_5_9
. But no influence.in.setVersion(QDataStream::Qt_4_3); out.setVersion(QDataStream::Qt_4_3);
What classes or functions to use to make the app appear new and competitive from the graphics point of view, please?
-
@tomy
It looks like the OS you are running on.
In this case windows 7.
It will look as win 10 when running on win 10 and so on.If you want to make other type of look, you can use stylesheets or make a completly new
QStyle class for it. In any way, its a lot of work. -
If you want to make other type of look, you can use stylesheets or make a completly new
QStyle class for it. In any way, its a lot of work.Do you think it's because of the old-fashioned book I use (C++-GUI-Programming-with-Qt-4-2ndEdition) or the look is the basic and I will use the new ones when I get further in the book?
-
-
Its how widget application looks. unless you make your own style.
What do you mean by that, please? do you mean I use some other classes for my app?
What minor changes I can do to my app to look a little nicer?It looks like all the other win 7 apps which is by design.
Hmm, but my prior app (Calculator) looks more graphical and resembles nowadays Wind 7/10 app!
-
@tomy A Qt app usually looks like any other app on the system where it is executed. On Windows 7 it looks like Windows 7 applications, on Windows 10 it looks like a Windows 10 application. Not sure why you bother about this while reading the book.
If you want your app to look differently then you can use stylesheets: http://doc.qt.io/qt-4.8/stylesheet-examples.html