Hi,

I would suggest that you store the WText pointers to some other place 
and access those widgets from there. You might not even need to store 
the WTable pointer (depends what you are doing and how are you doing it).

In my opinion using dynamic_cast can indeed solve the problem, and might 
even look like an elegant solution but in the long run using 
dynamic_cast will probably just cause more issues.  For example, if 
someone adds something else to the cell in addition to WText your 
solution using dynamic_cast will probably broke and it might be quite 
hard to find. I would dare to say that if you try to find a solution not 
using dynamic_cast you will end up with a better solution than the 
current one. I mean that is the code updating the table data doing too 
many things?

On 17.11.2010 18:03, Wim Dumon wrote:
> Always use dynamic_cast to upcast. dynamic_cast will return 0 if the
> object is of the wrong type. I believe this should work:
>
> WString tableText = dynamic_cast<WText
> *>(table->elementAt(0,0)->widget(0))->text());
>
> Wim.
>
> 2010/11/17 Magnus Arntzen<[email protected]>:
>> Hi.
>>
>> When I create a WTable and fill it with text, is it possible to access
>> that text again?
>>
>> ex:
>>
>> WTable *table = new WTable(this);
>> new WText("Hello World!", table->elementAt(0,0));
>>
>> WString tableText = table->elementAt(0,0)->text(); //WOULD BE NICE IF
>> THIS WORKED
>>
>> I tried casting the WTableCell to WInteractWidget and further to WText,
>> but dereferencing text() causes run-time error.
>>
>> Is there a way to do this?
>> (this is for printing/exporting table contents)
>>
>> Thanks!
>>
>> -Magnus
>>
>> ------------------------------------------------------------------------------
>> Beautiful is writing same markup. Internet Explorer 9 supports
>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2&  L3.
>> Spend less time writing and  rewriting code and more time creating great
>> experiences on the web. Be a part of the beta today
>> http://p.sf.net/sfu/msIE9-sfdev2dev
>> _______________________________________________
>> witty-interest mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/witty-interest
>>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2&  L3.
> Spend less time writing and  rewriting code and more time creating great
> experiences on the web. Be a part of the beta today
> http://p.sf.net/sfu/msIE9-sfdev2dev
> _______________________________________________
> witty-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/witty-interest

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to