1、QFileDialog ,允许用户选择一个或多个文件以及目录: QFileDialog *_openfile; QString file=openfile->getOpenFileName(this , QObject::tr("打开本地播放文件" ), "d:/" , QObject::tr("*.*" )); 2、绝对路径相对路径转换 QDir dirfrom; QFileInfo fileInfo(absopath); rabsopath=dirfrom.relativeFilePath(fileInfo.absoluteFilePath()); 3、将按钮设置为图标样式 pushButton->clearMask(); pushButton->setBackgroundRole( QPalette::Base); QPixmap mypixmap=new QPixmap(Iconpath); pushButton->setFixedSize( mypixmap.width(), mypixmap.height() ); pushButton->setMask(mypixmap.createHeuristicMask()); pushButton->setIcon(mypixmap); pushButton->setIconSize(QSize(mypixmap.width(),mypixmap.height())); pushButton->setToolTip(Iconname);