PDA

View Full Version : New to forum with some questions.



kd0afk
21st June 2009, 16:22
I am VERY new to programming with QT but I played around with basic many many years ago so please bear with me. I really like QT. It is a noobs dream.

I am wanting to do something that I think will be pretty simple. I would like to design a form that takes input from the user, takes those numbers, does some math and retrieves blocks of text and prints those blocks of text.
For instance, If I were to have a line edit and the user puts the number 5 into the box. The program would take that number and multiply it by 5, 10 and 20. The program would then return blocks of text (the resultant of the math will be in bold) like so:

-Hello, Johny went to the store and spent $25 on food.
-Johnny also spent $50 on gum.
Johnny spent $100 on lottery tickets.

I know that allot of it will be a regular "print" function. I want to have the blocks of text stored somewhere where they can be retrieved and the resultant numbers inserted into the blocks of text at the appropriate places and printed.

Can someone help me out on how to do this.
Thanks

QPlace
21st June 2009, 17:13
What you are asking people here to do is essentially to replace 30 mins of your own reading of Qt reference materials under "core feature" section with somebody's interpretation of the documents. To the exception of Mr. Wisota and several other "high-end" Qt experts on this forum, you are risking a chance that these comments will be of less quality then excellent documentation that comes with Qt.

Really, it will be more productive for you instead of asking "how to do this", ask for "please build me a sample project". With Qt it takes about 30 mins. Timing is for me only, I am sure that there are people on this forum that can complete it in less time then that. If, after reading the documentation for 30 mins, you still have problems of a "Can someone help me out on how to do this" type - let it be known and I will build you a start-up project with Qt and Vs2008.

Lykurg
21st June 2009, 17:14
E.g.: use QTextBrowser, set normal HTML for designing the text. Add the result of your math operation via QString::arg().


QTextBrowser tb;
QString html;
html.append("<html>....");
html.append(QString("<li>Johnny also spent <b>$%1</b> on gum.</li>").arg(10*userInput));
...
tb.setHtml(html);


Please also note our Newbie Section.

kd0afk
22nd June 2009, 17:57
What you are asking people here to do is essentially to replace 30 mins of your own reading of Qt reference materials under "core feature" section with somebody's interpretation of the documents. To the exception of Mr. Wisota and several other "high-end" Qt experts on this forum, you are risking a chance that these comments will be of less quality then excellent documentation that comes with Qt.

Really, it will be more productive for you instead of asking "how to do this", ask for "please build me a sample project". With Qt it takes about 30 mins. Timing is for me only, I am sure that there are people on this forum that can complete it in less time then that. If, after reading the documentation for 30 mins, you still have problems of a "Can someone help me out on how to do this" type - let it be known and I will build you a start-up project with Qt and Vs2008.
I will read up on QT more. The problem I am having is figuring out where in the documentation to find what I want. I am finding that something that could be said in plain english, isn't. There should be a tutorial on how to understand the language that the documentation is written in so that a person can find what they are looking for.

kd0afk
22nd June 2009, 17:59
E.g.: use QTextBrowser, set normal HTML for designing the text. Add the result of your math operation via QString::arg().


QTextBrowser tb;
QString html;
html.append("<html>....");
html.append(QString("<li>Johnny also spent <b>$%1</b> on gum.</li>").arg(10*userInput));
...
tb.setHtml(html);


Please also note our Newbie Section.

The bad news is, I that I didn't understand half of what you posted but, the good news is, I understood half of it. Thanks, I will look into it more.

jano_alex_es
23rd June 2009, 09:03
in my opinion you should start messing around with the designer, trying all the items and features, reading the qtAssistant EACH time you need help and when you are not able to continue, then ask in the newbie forum.

if you want to go further, you can buy the textbook "C++ GUI Programming with QT" (Prentice Hall), if you read it and if you do the exercises I can assure you you'll learnt a lot :P

Don't forget all the tutorials you have in the website.

But, answering your question, you can do it in several ways... using the QTextBrowser object (again, read all about it in the QT Assistant) or, for instance, creating a QEditText and a Qlabel, you will receive the data in the QEditText, you play with that info as you want and you can change the text of the label.