Be carefull with the above code, your using a pointer without alocating memory, instead do:
Qt Code:
To copy to clipboard, switch view to plain text mode
Be carefull with the above code, your using a pointer without alocating memory, instead do:
Qt Code:
To copy to clipboard, switch view to plain text mode
__________________________________________________
My projects: calculator MathGraphica ; SuperEpicMegaHero game ; GooglePlay ; bitbucket ; github
Like my projects ? Buy me a kofi
john_god, how your example differs from Rewo's example, those seems to be same?
The issue where you should be careful is that if the cell does not have item the item()-method returns NULL which means that you should check the validity of the pointer before accessing cell's content. That said this is implementation issue, if you implement your table in a way that there is always item in every cell then this kind of check is not needed. Next is a common pattern in my own table related handling methods:
Qt Code:
if (itab) { : : }To copy to clipboard, switch view to plain text mode
in the end, it's the same, but I'm simplifying code by eliminating itab an reading directly from item.
I agree with wath you said about cell validation, to me its all correct.
Just a side note, for writing cell content I usually do a pattern like this:
Qt Code:
if (tableWidget->item(i,j) == 0) { tableWidget->setItem(i,j, newItem); } else { tableWidgetMatrix->item(i, j)->setText("some text"); }To copy to clipboard, switch view to plain text mode
__________________________________________________
My projects: calculator MathGraphica ; SuperEpicMegaHero game ; GooglePlay ; bitbucket ; github
Like my projects ? Buy me a kofi
Bookmarks