本文整理汇总了C++中QFileDialog::setAcceptDrops方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileDialog::setAcceptDrops方法的具体用法?C++ QFileDialog::setAcceptDrops怎么用?C++ QFileDialog::setAcceptDrops使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileDialog
的用法示例。
在下文中一共展示了QFileDialog::setAcceptDrops方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void Dialog::on_button_1_clicked()
{
QFileDialog d;
//enum ViewMode { Detail, List };
d.setViewMode(QFileDialog::Detail);
//enum FileMode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly };
d.setFileMode(QFileDialog::ExistingFiles);
//enum AcceptMode { AcceptOpen, AcceptSave };
d.setAcceptDrops(QFileDialog::AcceptOpen);
//enum Option { ShowDirsOnly, DontResolveSymlinks, DontConfirmOverwrite, DontUseSheet, DontUseNativeDialog, ReadOnly, HideNameFilterDetails }
d.setOptions(QFileDialog::ReadOnly);
d.exec();
std::stringstream s;
if (d.result() == QDialog::Accepted)
{
s << "Number of files selected: " << d.selectedFiles().size() << '\n';
const auto v = d.selectedFiles();
for (auto f: v) s << f.toStdString() << '\n';
}
else
{
assert(d.result() == QDialog::Rejected);
s << "Dialog closed with cancel or close\n";
}
ui->text_1->setPlainText(s.str().c_str());
}
示例2: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QFileDialog d;
//enum ViewMode { Detail, List };
d.setViewMode(QFileDialog::Detail);
//enum FileMode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly };
d.setFileMode(QFileDialog::AnyFile);
//enum AcceptMode { AcceptOpen, AcceptSave };
d.setAcceptDrops(QFileDialog::AcceptSave);
//enum Option { ShowDirsOnly, DontResolveSymlinks, DontConfirmOverwrite, DontUseSheet, DontUseNativeDialog, ReadOnly, HideNameFilterDetails }
//Without QFileDialog::DontUseNativeDialog there will not be an edit box to supply
//a filename, under Lubuntu 13.04 (raring)
d.setOptions(QFileDialog::DontUseNativeDialog);
d.setWindowTitle("Save"); //Otherwise it states 'Open'
d.exec();
if (d.result() == QDialog::Accepted)
{
std::cout << "Number of files selected: " << d.selectedFiles().size() << '\n';
const auto v = d.selectedFiles();
for (auto s: v) std::cout << s.toStdString() << '\n';
}
else
{
assert(d.result() == QDialog::Rejected);
std::cout << "Dialog closed with cancel or close\n";
}
}