Home > Mobile >  How to judge whether the control is visible in the Qt? Such as switch TAB page to another page TAB i
How to judge whether the control is visible in the Qt? Such as switch TAB page to another page TAB i

Time:09-15

Here is visible and not hidden the (hide ()), but the interface switch, switch or TAB page lead to some of the controls are not currently visible,

I think when this control is not visible, if we can judge, not refresh it the status of the above, you can save system resources, because it has to refresh the data

CodePudding user response:

Can't use isVisible ()

CodePudding user response:

reference 1st floor mideum response:
with isVisible () no

No, isVisible () is a judgment whether to hide ()

CodePudding user response:

reference at the 2nd floor response:
no, isVisible () is a judgment whether to hide ()

Not oh, isHidden () is judge whether to hide, setVisible (true) after actually isVisible () do not necessarily return true
A widget is possible isHidden () and isVisible () returns false at the same time

CodePudding user response:

VisibleRegion () can solve part of the demand,
When as control, can use this to determine whether screening,
But cannot be used to determine whether another window in front of the window, this is also tested, not on the results,
If the window shade is the case, then the need to get it, basic is activeChange judgment of open Windows operating system have the rect covering their own,

The test results:
 # include "test7. H" 
#include

Test7: : test7 (QWidget * parent) : QWidget (parent)
{
This - & gt; The resize (500, 300);
This - & gt; SetAutoFillBackground (true);

T1=new QWidget (this);
T1 - & gt; show();
T1 - & gt; SetAutoFillBackground (true);
T1 - & gt; QWidget setStyleSheet (" {background: red; } ");
T2=new QWidget (this);
T2 - & gt; show();
T2 - & gt; SetAutoFillBackground (true);
T2 - & gt; QWidget setStyleSheet (" {background: green; } ");
T3=new QWidget (this);
T3 - & gt; show();
T3 - & gt; SetAutoFillBackground (true);
T3 - & gt; QWidget setStyleSheet (" {background: blue; } ");
T4=new QWidget (this);
T4 - & gt; show();
T4 - & gt; SetAutoFillBackground (true);
//t4 - & gt; QWidget setStyleSheet (" {background: black; } ");

T1 - & gt; SetGeometry (0, 0, 200, 100);
T2 - & gt; SetGeometry (0, 0, 100, 200);
T3 - & gt; SetGeometry (100, 100, 100, 100);
T4 - & gt; SetGeometry (100, 100, 100, 100);
}

Void test7: : moveEvent (QMoveEvent *)
{
QDebug () & lt; QDebug () & lt; }


 QRegion (null) QRegion (null) QRegion (null) QRegion (null) 
The QRegion (null)
200 x100 QRegion (0, 0) QRegion (0, 0, 100 x200) QRegion (null) QRegion 100 x100 (0, 0)
QRegion (size=4, bounds=(0, 0 500 x300) - [500 x100 (0, 0), (0100 100 x100), 300 x100 (200100), (0200, 500 x100)])


Can get effective shade, basically see the background color is empty, the background color is not obviously with QSS Settings, there is a QPaintEvent,
T4 transforming:
 class tt: public QWidget 
{
Q_OBJECT
Public:
Tt (QWidget * parent=0) : QWidget (parent) {}
Protected:
Void paintEvent (QPaintEvent *)
{
QPainter p (this);
P.f illRect (this - & gt; The rect (), Qt: : yellow);
}
};

 t4=new tt (this); 


 QRegion (null) QRegion (null) QRegion (null) QRegion (null) 
The QRegion (null)
200 x100 QRegion (0, 0) QRegion (0, 0, 100 x200) QRegion (null) QRegion 100 x100 (0, 0)
QRegion (size=4, bounds=(0, 0 500 x300) - [500 x100 (0, 0), (0100 100 x100), 300 x100 (200100), (0200, 500 x100)])


CodePudding user response:

Only within the Qt, you just need to control the background color is drawn out, packing have shade,
  •  Tags:  
  • Qt
  • Related