主要功能函数说明
1.获取手动打开的本地目录
//将取到的目录传给子线程
QString directory = QDir::toNativeSeparators(QFileDialog::getExistingDirectory());
if (directory.isNull()) {
return;
}
SPlayerPictureThread::getInstance().requestSetImagePath(directory);//
SPlayerPictureThread::getInstance().setThreadState(true,m_nPlayerSpeed);
2.将本地目录下的图片都放在m_photoPath容器中(传入的参数为1的地址)
void PlayerPicture::onNotifyPlayPictures(QString strPath)
{
QDir dir(strPath);
QStringList file;
QFileInfoList fileList = dir.entryInfoList(file,QDir::Files);
//保存图片所在的路径
QString fileDir;
//获取打开目录下的图片数据
for(int i=0;i<fileList.count();i++)
{
QFileInfo info = fileList.at(i);
fileDir.clear();
fileDir.append(getPicturePath() + “/”);
QString filename = info.fileName();
fileDir.append(filename);
// 把图片的路径装到容器中
m_photoPath.append(filename);
//跳过这两个目录
if(info.fileName() == “.” || info.fileName() == “…”)
{
continue;
}
}
}
3.在子线程中播放图片
void PlayerPicture::palyPictures()
{
m_tempDir.clear();
m_tempDir.append(getPicturePath()+"/"+m_photoPath.at(m_number));//拼接照片的绝对路径
m_number++;
//路径不是null
if ("" != m_tempDir){
m_playImage = m_tempDir;
//设置显示图片的窗口的 宽/高 为图片的 宽/高
if (m_pFrPriview->width() > m_playImage.width() || m_pFrPriview->height() > m_playImage.height()){
m_pFrPriview->resize(m_playImage.width(),m_playImage.height());
}
//加载需要播放的图片
m_pLbImage->setPixmap(m_playImage);
}