本文整理汇总了C++中QFileDialog::getOpenFileNames方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileDialog::getOpenFileNames方法的具体用法?C++ QFileDialog::getOpenFileNames怎么用?C++ QFileDialog::getOpenFileNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileDialog
的用法示例。
在下文中一共展示了QFileDialog::getOpenFileNames方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadMedia
void MainWindow::loadMedia(){
// mime database to detect file type
QMimeDatabase db;
// the mime type (to test if it is an audio file
QMimeType type;
// file list to be inserted into playlist
QStringList filelist;
// audio file to be opened
QFileDialog d;
filelist = d.getOpenFileNames(this,tr("Open File"),
"/home",
tr("Audio (*.wav *.mp3 *.ogg *.flac)"));
// retrieve mime type
for(QList<QString>::const_iterator it=filelist.begin(); it!= filelist.end(); it++){
type = db.mimeTypeForFile(*it);
// test if the file is an audio file
// if yes, send it to the playlist
if(type.name().startsWith("audio")){
playlist->addMedia(QUrl::fromLocalFile(*it));
}
}
}
示例2: settings
void MainWindow2::importImageSequence()
{
QFileDialog w;
w.setFileMode( QFileDialog::AnyFile );
QSettings settings( PENCIL2D, PENCIL2D );
QString initialPath = settings.value( "lastImportPath", QVariant( QDir::homePath() ) ).toString();
if ( initialPath.isEmpty() )
{
initialPath = QDir::homePath();
}
QStringList files = w.getOpenFileNames( this,
"Select one or more files to open",
initialPath,
"Images (*.png *.jpg *.jpeg *.bmp)" );
for ( QString strImgFile : files )
{
if ( strImgFile.endsWith( ".png" ) ||
strImgFile.endsWith( ".jpg" ) ||
strImgFile.endsWith( ".jpeg" ) ||
strImgFile.endsWith( ".bmp" ) )
{
mEditor->importImage( strImgFile );
mEditor->scrubForward();
}
}
}
示例3: on_addFileButton_clicked
void MainWindow::on_addFileButton_clicked(){
QFileDialog dialog;
SETTINGS();
QStringList files=dialog.getOpenFileNames(
this,
QString("Choose files to add"),
settings.value("main-window-add-files").toString(),
QString::null
);
if(files.empty()) return;
settings.setValue("main-window-add-files",files.at(0));
for(int i=0;i<files.count();i++){
addFile(files.at(i));
}
}
示例4: QFileDialog
void ImageFactory::exportImg()
{
QFileDialog *dial = new QFileDialog(this, Qt::Dialog);
QString dir = dial->getExistingDirectory(this, "Select the destination folder", QDir::currentPath(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
QStringList listPicture = dial->getOpenFileNames(this, "Select one or more files", QDir::currentPath(), "Image Files (*.png *.jpg *.jpeg *.bmp)");
if (!listPicture.isEmpty())
{
QString file;
QStringList::Iterator it = listPicture.begin();
while (it != listPicture.end())
{
QString dest = *it;
int index = dest.lastIndexOf("/");
std::cout << index << std::endl;
dest.remove(0, index);
file = "cp " + *it + " " + dir + dest;
const char *str = file.toStdString().c_str();
std::cout << str << std::endl;
system(str);
++it;
}
}
}
示例5: main
int main(int argc, char *argv[])
{
// QGuiApplication a(argc, argv);
QApplication a(argc, argv);
QwtPlot *plot = new QwtPlot();
QwtPlotCanvas *canvas = new QwtPlotCanvas();
canvas->setBorderRadius(10);
plot->setCanvas(canvas);
plot->setCanvasBackground(QColor("LIGHTGRAY"));
plot->enableAxis(QwtPlot::yRight);
plot->enableAxis(QwtPlot::xTop);
plot->setAxisTitle(QwtPlot::xBottom, "Xline");
plot->setAxisTitle(QwtPlot::xTop, "Xline");
plot->setAxisTitle(QwtPlot::yLeft, "Inline");
plot->setAxisTitle(QwtPlot::yRight, "Inline");
// float minx = srv->getStations().first().x();
// float maxx = srv->getStations().last().x();
plot->setAxisScale( QwtPlot::xBottom,3500,300);
// plot->setAxisScale( QwtPlot::xTop,minx,maxx );
// QwtScaleDraw *sd = axisScaleDraw( QwtPlot::yLeft );
// sd->setMinimumExtent( sd->extent( axisWidget( QwtPlot::yLeft )->font() ) );
plot->plotLayout()->setAlignCanvasToScales( true );
QFileDialog custDialog;
QStringList names = custDialog.getOpenFileNames(NULL, ("Open Files..."),QString(), ("UKOOA Files (*.p190 *.p90);;All Files (*)"));
// handle if the dialog was "Cancelled"
if(names.isEmpty())
{
return 0;
}
qSort(names.begin(), names.end());
QVector <QwtPlotCurve *> curves;
foreach (QString name, names)
{
QwtPlotCurve *vCurve = new QwtPlotCurve;
if(name.contains(QString( "NS1763")) || name.contains(QString("NS2029")))
{
QColor c = Qt::red;
vCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, Qt::red,c , QSize( 2, 2 ) ) );
}
else
{
QColor c = Qt::green;
vCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, Qt::green,c , QSize( 2, 2 ) ) );
}
vCurve->setStyle( QwtPlotCurve::NoCurve );
vCurve->setPen( Qt::gray );
cout << name.toStdString() << endl;
QVector<QPointF> curveData;
// m_nameLineLable->setText(m_names.at(0));
QFile *ukFile = new QFile(QString(name));
bool rt = ukFile->open(QIODevice::ReadOnly);
cout << "return " << rt << endl;
qint64 icount = 0;
qint64 fileSize = ukFile->size();
char *data = new char[fileSize];
ukFile->read(data,fileSize);
QString sData = data;
QString shot = "SNS";
while (true)
{
ukFile->seek(icount);
ukFile->read(data,fileSize);
sData = data;;
if(icount>=fileSize)
{
break;
}
auto sPos = sData.indexOf(shot,0,Qt::CaseInsensitive);
QString cr = sData.mid(sPos,19);
if(cr.contains("\n"))
{
sPos +=2;
}
// auto shotNo = sData.mid(sPos+20,sPos+5);
QString shotNo = sData.mid(sPos+19,6);
int shotNos;
if(shotNo.contains("\n") || shotNo.contains("\r"))
{
shotNo = sData.mid(sPos+19,8);
int shift1 = shotNo.indexOf("\r");
int shift = shotNo.indexOf("\n");
// cout << shift1 << " " << shift << endl;
QString tmp = shotNo.mid(0,shift1);
tmp.append(shotNo.mid(shift+1,3));
shotNos = tmp.toInt();
}
else
//.........这里部分代码省略.........