current position:Home>How to click two label controls in QT to subtract the customized numbers in the control

How to click two label controls in QT to subtract the customized numbers in the control

2022-02-02 19:11:15 CSDN Q & A

There are multiple label controls with different numbers ( Contains only numbers ), Click two tab controls in turn , Realize the subtraction of custom numbers in two label controls , Then save the result and put it into one of the two tags , Repeat until there is only one number left




Refer to the answer 1:

Implement the click message of the label control , Get the content of the tag , Convert to plastic , After successful subtraction, set it to the label .




Refer to the answer 2:



Refer to the answer 3:

Same as 1 floor , First, we need to implement the click event of the label control . If there is no problem with this, you can complete the following contents .
1. Define two global numeric variables , for example int numFirst=0,int numSecond =0;
2. Define a tab click count clickedCount=0;
3. Click the tab once , In the tag event clickedCount+1; At the same time, judge if clickedCount==1, Will numFirst = label.Text().toInt();, if clickedCount==2, Then assign numSecond , At the same time clickedCount Zeroing , And make a difference between the two numbers , Set the of one of the labels text by “”( empty ); Set another label number to difference .




Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202021911133369.html

Random recommended