stevenyao

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  22 随笔 :: 1 文章 :: 67 评论 :: 0 Trackbacks
很简单直接上代码:

#include <dwmapi.h>     // DWM APIs
#pragma comment(lib, "dwmapi"//DWM library

class MainWindow : public QMainWindow
{
public:
    MainWindow()
    {
        QPushButton 
*= new QPushButton("click me!"this);

        MARGINS mar 
= {4040100100}; //left, right, top, bottom margins.
        DwmExtendFrameIntoClientArea ( this->winId(), &mar ); //set the margins
    }

    
void paintEvent ( QPaintEvent * event )
    {
        QPainter p(
this);
        p.setCompositionMode(QPainter::CompositionMode_DestinationIn); 
//it's necessary!

        QRect rc 
= this->rect();
        p.fillRect(rc, QColor(
0000)); //the RGB color is not the point, the alpha value is.
    }
};

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    MainWindow mw;
    mw.show();

    app.exec();
}
posted on 2010-03-21 13:43 姚冬 阅读(1651) 评论(1)  编辑 收藏 引用

评论

# re: 在 QT 程序里使用Vista的 Glass 背景效果 2010-03-26 09:00 zmm
这段程序只能在vista,win7下运行吧?  回复  更多评论
  


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理