C++ and XAML - Numeric Input from Textbox - c++

This is my first forum post here. I'm new to c++ (been using MATLAB for years) and I am using visual studio's UWP template, creating the gui in the designer view, and trying to get inputs to do things in the background (I'm trying to make it matlab I guess lol). Every time I try to do this, it tella me that my inputs (input1->Text for example) are strings not double and I don't know how to get numeric inputs. New to this and very confused. Any guidance would be greatly appreciated :)
Thanks!
Brett

Since it is not clear you need C++/WinRT or C++/CX,I give the code for C++/CX by default.You can try the code below.
String^ text = MyTextBox->Text;
std::wstring ws1(text->Data());​
double num = std::stod(ws1);

Related

how to write code when form is loading in qt c++

I work with visual studio,before; when will write code in form_load event, must be double click in form and then write the code, Eevoudig So.
Now. I want write the code in form load in Qt,C++.
How and Where must write it?
Thank You,.
There is no form loading event. In C++ Qt projects, you should write your initialization code in the constructor of your form.
I figured out how to do it.
enter image description here
Writing the code in the red part is the solution to the problem.
The first part of the program that runs is the same.
Thank you. Good Bye.

How to get an int as input and project a double as output in an OpenGL C++ program?

I'm developing a OpenGL application in C++ however I require the user to input an int and the project to output a double plus some text. What would be the best way to go about this?
There's no text input function in OpenGL. You'll have to use an API on top of openGL, for example manage the keyboard entry with the basic GLUT keyboard functions.
For the output, you have to draw it as part of your graphic output as explained in this SO question.
Of course you don't need to reinvent the wheel from scratch and may consider more elaborate API than Glut, as discussed here.
Edit: Just seen today this tweet from Evan Todd with a link to his 160 lines of C++ implementation of in-game console on github. It's based on OpenGL/glfw. His approach could interest you as well.
Your job can be split into two part
Taking integer input from user
Show double + extra text it on your window
obviously second part is the easy part, use glutStrokeCharacter to show your double + text referred here
The first part is little bit tricker, you can make a TextEdit like widget using the glutStrokeCharacter & glutKeyboardFunc. The job of the TextEdit will to show the user original int input. just register the keyboard using glutKeyboardFunc & on the call back draw the original int inside the TextEdit widget.
glutKeyboardFunc is referrence here here
suggestion, draw a nice rectangle just behind the TextEdit's to make it seems actual user input :). Happy coding
Just found this actually which does exactly what I'm looking for. Thanks for all the responses.
https://justcheckingonall.wordpress.com/2008/08/29/console-window-win32-app/

How to get text to display in a TextBrowser in Qt?

I am new to c++ and even newer to Qt on Linux.
Can any one give me a general idea of how to display text in a textbrowser in Qt? I can't post my code because of the seative nature of the project I am working on. All I need is a basic understanding of how to do this related to slots and signals.
My application is this: I am taking input from a CSV file, counting the ords and then displaying the number of counted words along with the line of text in an output window.
It works fine in console c++ program. However, when I code it in Qt, it does not work.
Any advise or help would be welcome.
sorry for the bad question I asked earlier.
It turns out it was a configuration issue on my part.

how to write and read a text to and from a LineEdit using QT Creator?

I am working with QT Creator. I have a form that contains a push button and an Line Edit. I would like to print a string that i give programatically in this LineEdit.Secondly I would also like to the from the LineBox a string that I fill in and print it using QMessageBox.
How to do it? Need some help. I don't know how to access the displayText() to write and read from a LineEdit.
I would like to specify that I put the push button and the lineedit on the Form using drag and drop.
I am working in c++ under Ubuntu
Appreciate.
You use QLineEdit::setText() to change the text and QLineEdit::text() to read.
Your questions are very basic and show a clear lack of studying the documentation and experimenting thing yourself. Qt is one of the better documented frameworks out there and with lots of examples. Please take your time to go through them.

How can I get full string value of variable in VC6 watch window?

I'm wanting to get the full value of a char[] variable in the VC6 watch window, but it only shows a truncated version. I can copy the value from a debug memory window, but that contains mixed lines of hex and string values. Surely there is a better way??
For large strings, you're pretty much stuck with the memory window - the tooltip would truncate eventually.
Fortunately, the memory window is easy to get data from - I tend to show it in 8-byte chunks so its easy to manage, find your string data and cut&paste the lot into a blank window, then use alt+drag to select columns and delete the hex values. Then start at the bottom of the string and continually page up/delete (the newline) to build your string (I use a macro for that bit).
I don't think there's any better way once you get long strings.
Push come to shove you can put in the watch
given
char bigArray[1000];
watch:
&bigArray[0]
&bigArray[100]
&bigArray[200]
...
or change the index for where in the string you want to look...
Its clunky, but its worked for me in the past.
I do not have VC6 any more, so I cannot try it. I do not know if it works, but maybe you can enter
(char*)textArray;
in the watch window.
The bettter solution maybe: VS2008 automatically displays the text the way you want. And there is a Express Edition for VS2008 free of change, which can, as far as I know, be used to develop commerecial applications. You can even try to continue developing with VC6, and use VS2008 for debugging only. With VS2003 it was possible. About 5 year ago I had to maintain an app which was developed with VC6. I kept using VC6 for developing, but for debugging I used VS2003.
The only technique i have seen is to watch the string
then the string + 50, + 100 etc.
Eugene Ivakhiv wrote an addin for msvc 6 that lets you display the full string in an edit box.
There's a cute plugin for VC6 called XDebug. It adds a dialog for viewing different types of strings. It worked great for me.
Perhaps, get used to creating logfiles, and write output into the file directly, then bring up in your favorite text editor.