qt中截取桌面

    //获取桌面信息
    QDesktopWidget*desk = QApplication::desktop();
    //获取桌面的大小
    QRect rect = desk->screenGeometry();
    m_height = rect.height();
    m_width = rect.width();
    //qDebug()<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()<

你可能感兴趣的:(Qt学习,qt)