当前位置: 首页>>代码示例>>C++>>正文


C++ QFileDialog::getOpenFileNames方法代码示例

本文整理汇总了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));
    }
  }
}
开发者ID:cadubentzen,项目名称:blokbox_Cadu-Dina,代码行数:26,代码来源:mainwindow.cpp

示例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();
        }
    }
}
开发者ID:Forkhere,项目名称:pencil,代码行数:28,代码来源:mainwindow2.cpp

示例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));
	}
}
开发者ID:MiRiKan,项目名称:imas-psp,代码行数:20,代码来源:mainwindow.cpp

示例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;
        }
    }
}
开发者ID:k0ink0in,项目名称:TQ-WebCam,代码行数:23,代码来源:imagefactory.cpp

示例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
//.........这里部分代码省略.........
开发者ID:osamanagib,项目名称:UkooaFix,代码行数:101,代码来源:main.cpp


注:本文中的QFileDialog::getOpenFileNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。