QT 使用过程中用到的API

1.设置图标:this->setWindowIcon(QIcon("图标.ico"));

2.设置颜色:

ui->label_17->setStyleSheet("font-size:23px;color:red");   
ui->pushButton_3->setStyleSheet("background-color: rgb(238,154,0)");

3.int 转为QString:QString str = QString::number(Rec_buf[7],16).toUpper();

4.QString去空格:QString str_addr_1=ui->lineEdit_Read_zigbee_jump->text().remove(QRegExp("\\s"));

5.寻找QString中特定字符串的位置:int s2=str_jump_2.indexOf("name");

6.获取lineEdit内容:QString str_addr_2=ui->lineEdit_Read_zigbee_jump->text();

7.插入lineEdit:ui->lineEdit_SOIL_PH->insert("hello");

8.doubleSpinBox:ui->doubleSpinBox_air_speed->setValue(air_speed/100);

9.插入Plain Text Edit :ui->recvTextBrowser->insertPlainText("\n");

10.char  QByteArray:

char send[8]={0xFE,0x05,0x90,0x21,0x00,0x00,0x04,0xFF};

QByteArray senddata=QByteArray::fromRawData(send,8);

serial.write(senddata);

你可能感兴趣的:(QT)