本文整理汇总了C++中QWidget::colorGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::colorGroup方法的具体用法?C++ QWidget::colorGroup怎么用?C++ QWidget::colorGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::colorGroup方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setState
void TransparentPlugin::setState()
{
QWidget *main = getMainWindow();
if (main == NULL)
return;
#ifdef WIN32
if (timer == NULL){
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(tick()));
main->installEventFilter(this);
SetWindowLongW(main->winId(), GWL_EXSTYLE, GetWindowLongW(main->winId(), GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(main->winId(), main->colorGroup().background().rgb(), 0, LWA_ALPHA);
RedrawWindow(main->winId(), NULL, NULL, RDW_UPDATENOW);
main->setMouseTracking(true);
m_bActive = main->isActiveWindow();
m_bState = !m_bActive;
}
bool bNewState = m_bActive || m_bHaveMouse;
if (bNewState == m_bState){
BYTE d = (BYTE)(bNewState ? 255 : QMIN((100 - getTransparency()) * 256 / 100, 255));
SetLayeredWindowAttributes(main->winId(), main->colorGroup().background().rgb(), d, LWA_ALPHA);
return;
}
m_bState = bNewState;
startTime = GetTickCount();
timer->start(10);
#else
if (!top) {
top = new TransparentTop(main, getTransparency());
connect(top,SIGNAL(destroyed()),this,SLOT(topDestroyed()));
}
top->setTransparent(getTransparency());
#endif
}
示例2: transparentChanged
void TransparentTop::transparentChanged()
{
#ifdef WIN32
if (bCanTransparent){
QWidget *p = static_cast<QWidget*>(parent());
if (*useTransparent){
if (!m_bUseTransparent){
SetWindowLongW(p->winId(), GWL_EXSTYLE, GetWindowLongW(p->winId(), GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(p->winId(), p->colorGroup().background().rgb(), 255, LWA_ALPHA);
if (p->isVisible())
RedrawWindow(p->winId(), NULL, NULL, RDW_UPDATENOW);
p->installEventFilter(this);
m_bUseTransparent = true;
}
}else{
if (m_bUseTransparent){
SetWindowLongW(p->winId(), GWL_EXSTYLE, GetWindowLongW(p->winId(), GWL_EXSTYLE) & ~WS_EX_LAYERED);
p->removeEventFilter(this);
m_bUseTransparent = false;
}
}
}
#endif
setTransparent();
}
示例3: tick
void TransparentPlugin::tick()
{
#ifdef WIN32
QWidget *main = getMainWindow();
if (main == NULL){
timer->stop();
return;
}
unsigned timeout = m_bActive ? SHOW_TIMEOUT : HIDE_TIMEOUT;
unsigned time = GetTickCount() - startTime;
if (time >= timeout){
time = timeout;
timer->stop();
}
if (m_bState)
time = timeout - time;
BYTE d = (BYTE)QMIN((100 - getTransparency() * time / timeout) * 256 / 100, 255);
SetLayeredWindowAttributes(main->winId(), main->colorGroup().background().rgb(), d, LWA_ALPHA);
#endif
}
示例4: eventFilter
bool TransparentTop::eventFilter(QObject *o, QEvent *e)
{
switch (e->type()){
case QEvent::WindowActivate:
case QEvent::WindowDeactivate:
setTransparent();
break;
case QEvent::Show:
#ifdef WIN32
if (bCanTransparent){
QWidget *w = static_cast<QWidget*>(o);
SetLayeredWindowAttributes(w->winId(), w->colorGroup().background().rgb(), 255, LWA_ALPHA);
QTimer::singleShot(0, this, SLOT(setTransparent()));
}
#endif
break;
default:
break;
}
return false;
}
示例5: popupDetail
void QTextBrowser::popupDetail( const QString& contents, const QPoint& pos )
{
const int shadowWidth = 6; // also used as '5' and '6' and even '8' below
const int vMargin = 8;
const int hMargin = 12;
QWidget* popup = new QTextDetailPopup;
popup->setBackgroundMode( QWidget::NoBackground );
QSimpleRichText* doc = new QSimpleRichText( contents, popup->font() );
doc->adjustSize();
QRect r( 0, 0, doc->width(), doc->height() );
int w = r.width() + 2*hMargin;
int h = r.height() + 2*vMargin;
popup->resize( w + shadowWidth, h + shadowWidth );
// okay, now to find a suitable location
//###### we need a global fancy popup positioning somewhere
popup->move(pos - popup->rect().center());
if (popup->geometry().right() > QApplication::desktop()->width())
popup->move( QApplication::desktop()->width() - popup->width(),
popup->y() );
if (popup->geometry().bottom() > QApplication::desktop()->height())
popup->move( popup->x(),
QApplication::desktop()->height() - popup->height() );
if ( popup->x() < 0 )
popup->move( 0, popup->y() );
if ( popup->y() < 0 )
popup->move( popup->x(), 0 );
popup->show();
// now for super-clever shadow stuff. super-clever mostly in
// how many window system problems it skirts around.
QPainter p( popup );
p.setPen( QApplication::palette().active().foreground() );
p.drawRect( 0, 0, w, h );
p.setPen( QApplication::palette().active().mid() );
p.setBrush( QColor( 255, 255, 240 ) );
p.drawRect( 1, 1, w-2, h-2 );
p.setPen( black );
doc->draw( &p, hMargin, vMargin, r, popup->colorGroup(), 0 );
delete doc;
p.drawPoint( w + 5, 6 );
p.drawLine( w + 3, 6,
w + 5, 8 );
p.drawLine( w + 1, 6,
w + 5, 10 );
int i;
for( i=7; i < h; i += 2 )
p.drawLine( w, i,
w + 5, i + 5 );
for( i = w - i + h; i > 6; i -= 2 )
p.drawLine( i, h,
i + 5, h + 5 );
for( ; i > 0 ; i -= 2 )
p.drawLine( 6, h + 6 - i,
i + 5, h + 5 );
}