基本上我有一个完整的控制台应用程序,在多个cpp文件中随处可见cout / cin。对于我的应用程序,cin取0-7的数字,因此gui可能有0-7等按钮。只需通过打印到GUI上的文本框来替换cout。
cout << "WELCOME TO YOUR PERSONAL FINANCE ACCOUNT SYSTEM" << endl; //MAIN MENUS
cout << "Please Select an account to access: " << endl;
cout << "1. Stock Portfolio Account" << endl;
cout << "2. Bank Account" << endl;
cout << "3. Design Pattern Settings" << endl; // USER CAN PICK DEISGN PATTERNS HERE
cout << "4. Exit" << endl;
int access;
cin >> access;
switch (access) {
case 1: {
stockAccount->main_menu(portfolio, bankAccount);
break; }
case 2: {
bankAccount->main_menu(portfolio, stockAccount);
break; }
case 3: {
cout << endl;
cout << "Personal Assistor: " << endl;
cout << "1. OFF: " << endl;
cout << "2. ON: " << endl;
cout << endl; cout << endl;
cout << "Sorting Method: " << endl;
cout << "3. Selection Sort - Optimal Data Movement: a simple sort. " << endl;
cout << "4. Insertion Sort: - Optimal for investors who pick stocks near the same value " << endl;
int choice;
cin >> choice;
switch (choice) {
case 1: {
acc->assist = false;
cout << endl;
cout <<"Personal Assistor Turned OFF "<<endl;
ofstream fout;
fout.open("assist.txt");
fout << "OFF";
fout.close();
break; }
case 2: {
cout << endl;
cout << "Personal Assistor Turned ON " << endl;
ofstream fout;
fout.open("assist.txt");
fout << "ON";
fout.close();
acc->assist = true;
break; }
case 3: {
cout << endl;
cout << "SORT ALGORITHM: SELECTION SORT" << endl;
ofstream fout;
fout.open("sort.txt");
fout << "sel";
fout.close();
break; }
case 4: {
cout << endl;
cout << "SORT ALGORITHM: INSERTION SORT" << endl;
ofstream fout;
fout.open("sort.txt");
fout << "ins";
fout.close();
break; }
}
main(1);
return 0;
break; }
case 4: {
cout <<"Have a nice day!"<< endl;
return 0;
break; }
default: {
cout <<"Please Enter a Valid Number"<< endl;
main(1);
}
}
我已经通过QT查看,这对学习曲线来说太难了(我只需要这个gui进行短期课程作业,而不是为了自己的学习而学习它),教授说要使用我们想要的任何东西。我查看了窗体。我只需要一个教程告诉我这个:
1)这里是按钮,每个按钮输入一个数字
2)如果按下SAID按钮,输出字符串到GUI文本框(输出字符串到gui文本框 - 意味着多个.cpp文件中的所有cout都打印到gui文本框,因为我输入相应的数字/等。)
同样,对于一个简短的任务,我没有时间彻底学习任何复杂的GUI应用程序开发,如果有任何简单的例子,请告诉我。我知道我必须改变cin / couts,但这就是我想改变的全部内容。谢谢
答案 0 :(得分:0)
从Visual Studio创建基于对话框的mfc应用程序。
简单,只需从IDE侧的工具箱拖放按钮和文本框即可。双击按钮,将转到将在该按钮单击时执行的功能。