1919 views|2 replies

164

Posts

0

Resources
The OP
 

itop4412 development board Qt serial port programming-interface layout [Copy link]

In this section, we use Qt to write a simple host computer.
Experimental introduction: Assemble the UI interface and use the serial port class provided by Qt to implement the serial port receiving and sending functions. The relevant Qt knowledge that needs to be mastered are as follows:
QSerialPort is an additional module in Qt5, which provides basic functions, including configuration, I/O operation, obtaining and setting the signal of RS-232 pins. To link the QtSerialPort module, you need to add +=serialport in the .pro file.
QSerialPort encapsulates a wealth of member variables to correspond to serial port properties, and there are many member functions for operating serial ports. Commonly used member functions include setPort() or setPortName(), setBaudRate(), setDataBits(), setStopBits(), setParity(), etc. These functions can be used to set the serial port device to be accessed. This experiment uses the readyRead() signal. When data arrives, the readyRead() signal of the class object will be triggered, and then its member function readAll() will be used to read.
The class QSerialPortInfo can obtain available serial port information, such as port name, system location, product number, description, manufacturer and other information. We pass the obtained port information to the QSerialPort class object.
77.1 Interface layout
Step 1: Drag the controls to the UI interface
Use Plain Text Edit for the receiving box, lineEdit for the sending box, and Combo Box for the property selection component.


Step 2: Layout of the property setting bar. Take the serial port number as an example and layout the property selection bits horizontally in sequence.

Then select all the property selection boxes and click vertical layout

The effect is as follows:

Step 3: Layout of the function bar. Add springs between the buttons and click horizontal layout.

Select Lbel, the send box and the function button, and click on the vertical layout

As shown:

Select the property bar and the components on the right, and then click on the horizontal layout, as shown:

After completion:

Follow the above method to vertically layout the function part and the receiving box below:

After adding the components, change the receiving box to read-only: Click on the receiving box and mark readOnly in QTextEdit.
Change the UI interface object name in the upper right corner. After the interface is assembled, you can modify it as needed.
Double-click the attribute selection box to add attributes:

As shown:



Search for more content on Bilibili

This post is from ARM Technology

Latest reply

Thanks for sharing!   Details Published on 2021-4-12 22:39
 

6547

Posts

0

Resources
2
 

It seems that there is no problem with the interface of the host computer.

This post is from ARM Technology
 
 
 

7422

Posts

2

Resources
3
 

Thanks for sharing!

This post is from ARM Technology
 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list