qt中截取桌面

来源:互联网 发布:北京到底有多大 知乎 编辑:程序博客网 时间:2024/05/20 15:57
    //获取桌面信息    QDesktopWidget*desk = QApplication::desktop();    //获取桌面的大小    QRect rect = desk->screenGeometry();    m_height = rect.height();    m_width = rect.width();    //qDebug()<<desk->screenCount();        //获取应用程序的主屏幕    QScreen*screen = QGuiApplication::primaryScreen();    QPixmap map = screen->grabWindow( desk->winId() , 0 , 0 , m_width , m_height );    this->resize( m_width , m_height );    QLabel *label=new QLabel(this);    label->setGeometry(0,0,m_width,m_height);    label->setPixmap(map);    label->show();    qDebug()<<m_height<<m_width;

1 0