Qt随笔

1)设置widget屏幕居中

 

QDesktopWidget* desktop = QApplication::desktop();
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++;

 


 

 

 

 

 

posted @ 2010-07-27 16:04  Carrot  阅读(184)  评论(0编辑  收藏  举报