Qt in the event of a crash QLineEdit set text setText

Reference example: https://blog.csdn.net/u014252478/article/details/80377103 learning QT Socket programming.
When you run TcpServer program crashes, nasty Segmentation fault appeared!

The call stack shows QLineEdit call setText position is likely to be a problem QLineText pointer!
 
The QNetworkInterface (). AllAddresses (). At (1) .toString () call to open the cascade debugging, get ip string is not a problem, judging ui-> IPEdit pointer is NULL, no problem!
Careful observation, found the problem:
ui-> setupUi (the this); on the construction of the final, no setupUI went to use UI, so he wrong!
Solve: Sets up the user interface for the specified widget front called first in the constructor!!

Successful operation:

PS: There is also a sample program client ui button signal slots are not successfully connect and send Chinese garbled and other issues, this can get their own, as a learning material.

Guess you like

Origin www.cnblogs.com/MakeView660/p/12200441.html