C++ String Converting with wx

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
dragonMan
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Jun 06, 2021 10:25 am

C++ String Converting with wx

Post by dragonMan »

ggegrgr.png
ggegrgr.png (17.73 KiB) Viewed 1690 times

I am stuck for 1 hour. Please help
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: C++ String Converting with wx

Post by doublemax »

It's not totally clear what you're lookin for. Converting an integer to a string?
https://wiki.wxwidgets.org/Converting_e ... o_wxString
Use the source, Luke!
dragonMan
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Jun 06, 2021 10:25 am

Re: C++ String Converting with wx

Post by dragonMan »

So the problem is that the text is not changing its value after the button is being pressed and I don't know how to update that. Know something that would come in handy?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: C++ String Converting with wx

Post by ONEEYEMAN »

Hi,
What do you expect to to see as the label? The value of i? Anything else?

Just follow doublemax' suggestion and the call SetLabel() on the button with appropriate text.

Thank you.
dragonMan
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Jun 06, 2021 10:25 am

Re: C++ String Converting with wx

Post by dragonMan »

Yes, the value of i. How do I use SetLabel()?
Kvaz1r
Super wx Problem Solver
Super wx Problem Solver
Posts: 357
Joined: Tue Jun 07, 2016 1:07 pm

Re: C++ String Converting with wx

Post by Kvaz1r »

Code: Select all

m_button->SetLabel(labelText);
Btw, there is widgets sample that allow to see what one can do with different widgets.
dragonMan
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Jun 06, 2021 10:25 am

Re: C++ String Converting with wx

Post by dragonMan »

hey,

thanks for the help. but can I get the SetLabel() function explained a little bit more? The point is that I want to do a clicker game so if I click the 'get points' button the 'i' value gets +1 point and the StaticText prints out the 'i' value. Think you can help?
Kvaz1r
Super wx Problem Solver
Super wx Problem Solver
Posts: 357
Joined: Tue Jun 07, 2016 1:07 pm

Re: C++ String Converting with wx

Post by Kvaz1r »

Just combine code from previous messages:

Code: Select all

widget->SetLabel(wxString::Format("%i", i));
where widget is your wxStaticText.
Post Reply