Qt随笔
1)设置widget屏幕居中
QDesktopWidget* desktop = QApplication::desktop();
move((desktop->width() - this->width())/2, (desktop->height() - this->height())/2);
move((desktop->width() - this->width())/2, (desktop->height() - this->height())/2);
2)Print screen
QImage image(768,1024,QImage::Format_Indexed8);
memcpy(image.bits(),QScreen::instance()->base(), 768 * 1024);
QString fileToSave = QString("/resource/shot_");
fileToSave.append(QString::number(m_fileNum));
fileToSave.append(".png");
if(image.save(fileToSave,"PNG"))
qDebug()<<"Image saved :"<<fileToSave;
m_fileNum++;