Ehm, here:
Create int, double etc. on the stack:, and, what is the alternative and how should I have done this?
Ehm, here:
Create int, double etc. on the stack:, and, what is the alternative and how should I have done this?
I need a bit of reading. I'll do that.
I taken both your advice and produced this, which works very well. I can continue working with this.
Qt Code:
void Dconvert::convert() { double resultaat; resultaat = (inputLine->text().toDouble()); resultLine->setText(resultstring); }To copy to clipboard, switch view to plain text mode
Ah, you are an user that reads the docs! That's great
Some point on your code: the enclosing brackets are not needed and if you are not going to alter resultstring (I suppose so), then avoid creating a temporary variable. Just pass it to your function. And if you put a variable to your slots, you don't have to request the value of your lineedit, because it is already send by the signal.
Qt Code:
//... { double resultaat = value.toDouble(); // convert an alter resultaat }To copy to clipboard, switch view to plain text mode
Thanks for your latest comments about my code. I appreciate such small corrections a lot.
I did my homework.
The stack is the 'regular' memory where variables are stored. The heap is the memory between the program code and the stack. It is FINITE in size. That is why you mentioned not to create variables in the heap?
I saw the difference and learned that created variables in heap must also be destroyed using delete.
Is there any other reason why not to use the heap for regular variables?
Allocating memory on the stack simply implies subtracting a value from the stack pointer; allocating on the heap involves a more complicated function call with higher overhead which only makes sense for larger datastructures.Is there any other reason why not to use the heap for regular variables?
The stack and heap are both finite in size, but there is typically more memory available on the heap.
Bookmarks