我正在学习C++,我遇到了两种编写代码的不同类型,我想知道它们之间的区别.
之间有什么区别:
if(z==true)
{
cout << "Yes";
}
else
{
cout << "NO";
}
Run Code Online (Sandbox Code Playgroud)
和:
if(z==true)
cout << "YES";
else
cout << "NO";
Run Code Online (Sandbox Code Playgroud) 我是Qt/C++的初学者,所以当我从一些教程中学习时,我想做一些除了教程之外的东西但却不知道具体的方式.
这是代码,我正在使用http://pastebin.com/x612nAPV
#include "dialog.h"
#include "ui_dialog.h"
#include <QtGui>
#include <QMessageBox>
#include <QString>
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
//ui->checkBox->setChecked(true);
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog::on_pushButton_clicked()
{
if(ui->checkBox->isChecked())
{
QMessageBox::information(this,"Result","Cool another Male !");
}
if(ui->checkBox_2->isChecked())
{
QMessageBox::information(this,"Result", "Yay a female");
}
}
Run Code Online (Sandbox Code Playgroud)
我想做的是制作一个if()包含2个变量的第三个,这样在这种情况下如果没有选中复选框来显示消息,但我不知道如何在qt里面使用2个变量
喜欢
if(2variableshere)
{
Do...
}
Run Code Online (Sandbox Code Playgroud) 我是一个学习Qt/C++的初学者,我遇到了一个错误:我想知道如何在这种情况下将变量放在下面几行中字符串旁边的"username"中.
QString username = ui->lineEdit->text();
QMessageBox msgBox;
msgBox.setText("Your username is: " VARIABLEHERE);
msgBox.exec();
Run Code Online (Sandbox Code Playgroud)
那么如何排队或者我应该使用其他功能?比msgBox.setText()