2019年8月2日 星期五

【Qt】ComboBox 下拉式選單

【Qt】ComboBox 下拉式選單

1. 建立選單資料

ui->ComboBox->insertItem(0,"ONE")
ui->ComboBox->insertItem(1,"SEC")

【Qt】開啟文件

【Qt】開啟文件

如何在視窗中設置開啟檔案:

1. 使用QFileDialog
#include<QFileDialog>

2. 在事件中加入
QString Filename = QFileDialog::getOpenFileName(this,
                      "Open File","C:\\", "Text Files (*.txt *.NC *.CNC)");
觸發時會呼叫一個開啟檔案的視窗

【Qt】視窗中顯示中文

【Qt】視窗中顯示中文

由於視窗創建時無法印出中文字原(編碼無法是別),所以會印出亂碼!
這邊介紹兩鐘方式可以印出中文字。

1.在main.cpp中加入以下程式
#include<QTextCodec>
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));

2019年8月1日 星期四

【Qt】取得系統時間

【Qt】取得系統時間

使用 QDateTime

QDateTime time = QDateTime::currentQDateTime();    //取得系統時間
QString str = time.toString("yyyy-MM-dd hh:mm:ss ddd");    // 設置顯示格式

【Arduino】 RS485 實現Modbus Slave

 這次使用Arduino UNO + RS485 的模組,來實現Modbus Slave 的通訊 Pin Name Pin Description VCC 5V A Non-inverting Receiver Input Non-Inverting Driver Output ...