Home > other >  Using qt made up of two interfaces, how get data on one interface real-time display on the second in
Using qt made up of two interfaces, how get data on one interface real-time display on the second in

Time:04-20

Everybody is good, now I have a question want to ask, thank you! I use qt made up of two interface, might as well respectively named form1. The UI and form2. UI, set a button in the form1, click on the pop-up form2 (can be), set in the form1 another button, click on the perform data collection procedures, can undertake data collection, I'd like to take this time to collect real-time data display in form2 but I tried several methods, form1 how the data collected are not shown in form2, don't know how to implement this function, thank you

CodePudding user response:

Set form1. UI appropriate class for form1Classform2. UI appropriate class for form2Class, data acquisition program should be a time-consuming operation, you will need to open another thread to do data collection work, if do, in the main thread interface can't response message, more can't real-time data from the reality, set the worker thread for SampleThread, class form1Class {... Form1Class FRM; SampleThread * procTrd; Void OnProcBtnClicked ();//btn1 the response function of the button is clicked signals void OnShowFrm1BtnClicked ();//btn2 button clicked signals of the response function of the... }; Define a signal in SampleThread: void ShowData (QString& Data), emit yourself when you need real data, define a slot in the form2Class: void OnShowData (QString& ShowData data) for response signal, the signal and slot in form1Class connection is good, OnProcBtnClicked started collecting threads, thread run function in place of emit ShowData

CodePudding user response:

Hello my two interfaces are upstairs with qt designer, with some in form2 lineedit, the edit box is used for displaying the data to collect, assumes that the collection of data in the form1 respectively in data1, data2... Datan, the following program how to write? Thank you very much!

CodePudding user response:

Add a method call in form1, after data collection, through determine which data changes, and then sent via adds to form2 window, so the fastest or directly through the form2 class pointer is added in the form1 to operate

CodePudding user response:

Directly through added in the form1 form2 class pointer to operate? How to do? I set up in the form1 form2 form a pointer, form2 * dialog1=new form2 (this, "form2", TRUE); Dialog1 - & gt; The exec (); And defines the lineedit in Form2 name for lineedit1,... , lineedit10 (assuming 10 edit box) when I'm in form1 dialog1 - & gt; Settext (lineedit1 (tr "4")), an error says lineedit1 does not define whether should put lineedit1 defined as public or something? But I don't know how to define, thank you teach

CodePudding user response:

This way you can do this Form2 * dialog1=new Form2 (this, "Form2", TRUE); The connect (this, SIGNAL (), dialog1, SLOT ()); To do

CodePudding user response:

The building Lord solved excuse me? Meet the same problem
  • Related