Drawing an overlay on top of an application's window

后端 未结 2 1688
自闭症患者
自闭症患者 2020-12-31 05:19

I want to be able to paint on top of my application\'s window so that I can annotate all the widgets with some extra diagnostic information, similar to the CSS developer too

2条回答
  •  再見小時候
    2020-12-31 05:53

    You can create own style class based on QMotifStyle or other ... and paint on any widget/control related to him information.

    void MyStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,QPainter *painter, const QWidget *widget) const
    {
         QStyle::State flags = option->state;
         QRect      rect     = option->rect;
         QPalette   pal      = option->palette;
         QBrush brush;
    
        switch (element)
        {
            case PE_FrameTabWidget:
            {
                 painter->save();
    
                     // for example: draw anything on TabWidget
                    painter->drawPixmap(rect,centerPm,centerPm.rect());
                 painter->restore();
            }
            break;
            default:
             QMotifStyle::drawPrimitive(element, option, painter, widget);
             break;
    
        }
    }
    

提交回复
热议问题