以qt5形式发送数据
send data beteen form qt5
我想从一个发送数据到另一个
我是 qt 的新手,我用谷歌搜索了我的问题并找到了很多解决方案
但没有人关注一个 qstring 值
login.cpp
void Login::GetSerial()
{
QString s1 = cmd("WMIC cpu get ProcessorId");
s1 = s1.replace("ProcessorId","");
s1= s1.simplified();
s1.replace(" ","");
QString r1 = cmd("WMIC BaseBoard get serialnumber");
r1 = r1.replace("SerialNumber","");
r1= r1.simplified();
r1.replace(" ","");
QString text = s1;
QString key = r1;
QByteArray text_bin;
text_bin = QByteArray::fromHex(text.toUtf8());
QTextCodec *codec = QTextCodec::codecForName("UTF-16");
QTextEncoder *encoder = codec->makeEncoder(QTextCodec::IgnoreHeader);
text_bin = encoder->fromUnicode(text);
text_bin = text.toLocal8Bit();
QByteArray key_bin = key.toUtf8();
QByteArray decrypted = aes->decrypt(text_bin, key_bin, nullptr);
QString s = decrypted.toHex();
int x = s.size();
QString r = s.remove(12,x);
r = r.toUpper();
ui->LblSn->setText("SN : " + r);//qstring r is the value i want to sent it to second
}
我想以第二种形式将 form1 中的值放入 qlabel
这是第二种形式
register.cpp
Register::Register(QWidget *parent) :
QWidget(parent),
ui(new Ui::Register)
{
ui->setupUi(this);
QRegExp rx(EMAIL_RX);
QRegExpValidator *vali = new QRegExpValidator(rx,this);
ui->Txtemail->setValidator(vali);
}
Register::~Register()
{
delete ui;
}
void Register::on_BtnLogin_clicked()
{
Login *l = new Login();
l->show();
hide();
}
这对我有用
QString Seria;
void Login::setLabelT(const QString& title)
{
ui->LblSn->setText(title);
}
void Login::GetSerial()
{
QString s1 = cmd("WMIC cpu get ProcessorId");
s1 = s1.replace("ProcessorId","");
s1= s1.simplified();
s1.replace(" ","");
QString r1 = cmd("WMIC BaseBoard get serialnumber");
r1 = r1.replace("SerialNumber","");
r1= r1.simplified();
r1.replace(" ","");
QString text = s1;
QString key = r1;
QByteArray text_bin;
text_bin = QByteArray::fromHex(text.toUtf8());
QTextCodec *codec = QTextCodec::codecForName("UTF-16");
QTextEncoder *encoder = codec->makeEncoder(QTextCodec::IgnoreHeader);
text_bin = encoder->fromUnicode(text);
text_bin = text.toLocal8Bit();
QByteArray key_bin = key.toUtf8();
QByteArray decrypted = aes->decrypt(text_bin, key_bin, nullptr);
QString s = decrypted.toHex();
int x = s.size();
QString r = s.remove(12,x);
r = r.toUpper();
ui->LblSn->setText("SN : " + r);
Seria = "SN : " + r;
}
register.cpp
void Register::setLabelTitle(const QString& title)
{
ui->LblSnR->setText(title);
}
我想从一个发送数据到另一个
我是 qt 的新手,我用谷歌搜索了我的问题并找到了很多解决方案 但没有人关注一个 qstring 值
login.cpp
void Login::GetSerial()
{
QString s1 = cmd("WMIC cpu get ProcessorId");
s1 = s1.replace("ProcessorId","");
s1= s1.simplified();
s1.replace(" ","");
QString r1 = cmd("WMIC BaseBoard get serialnumber");
r1 = r1.replace("SerialNumber","");
r1= r1.simplified();
r1.replace(" ","");
QString text = s1;
QString key = r1;
QByteArray text_bin;
text_bin = QByteArray::fromHex(text.toUtf8());
QTextCodec *codec = QTextCodec::codecForName("UTF-16");
QTextEncoder *encoder = codec->makeEncoder(QTextCodec::IgnoreHeader);
text_bin = encoder->fromUnicode(text);
text_bin = text.toLocal8Bit();
QByteArray key_bin = key.toUtf8();
QByteArray decrypted = aes->decrypt(text_bin, key_bin, nullptr);
QString s = decrypted.toHex();
int x = s.size();
QString r = s.remove(12,x);
r = r.toUpper();
ui->LblSn->setText("SN : " + r);//qstring r is the value i want to sent it to second
}
我想以第二种形式将 form1 中的值放入 qlabel 这是第二种形式
register.cpp
Register::Register(QWidget *parent) :
QWidget(parent),
ui(new Ui::Register)
{
ui->setupUi(this);
QRegExp rx(EMAIL_RX);
QRegExpValidator *vali = new QRegExpValidator(rx,this);
ui->Txtemail->setValidator(vali);
}
Register::~Register()
{
delete ui;
}
void Register::on_BtnLogin_clicked()
{
Login *l = new Login();
l->show();
hide();
}
这对我有用
QString Seria;
void Login::setLabelT(const QString& title)
{
ui->LblSn->setText(title);
}
void Login::GetSerial()
{
QString s1 = cmd("WMIC cpu get ProcessorId");
s1 = s1.replace("ProcessorId","");
s1= s1.simplified();
s1.replace(" ","");
QString r1 = cmd("WMIC BaseBoard get serialnumber");
r1 = r1.replace("SerialNumber","");
r1= r1.simplified();
r1.replace(" ","");
QString text = s1;
QString key = r1;
QByteArray text_bin;
text_bin = QByteArray::fromHex(text.toUtf8());
QTextCodec *codec = QTextCodec::codecForName("UTF-16");
QTextEncoder *encoder = codec->makeEncoder(QTextCodec::IgnoreHeader);
text_bin = encoder->fromUnicode(text);
text_bin = text.toLocal8Bit();
QByteArray key_bin = key.toUtf8();
QByteArray decrypted = aes->decrypt(text_bin, key_bin, nullptr);
QString s = decrypted.toHex();
int x = s.size();
QString r = s.remove(12,x);
r = r.toUpper();
ui->LblSn->setText("SN : " + r);
Seria = "SN : " + r;
}
register.cpp
void Register::setLabelTitle(const QString& title)
{
ui->LblSnR->setText(title);
}