本文整理汇总了C++中QString::GET_ASCII方法的典型用法代码示例。如果您正苦于以下问题:C++ QString::GET_ASCII方法的具体用法?C++ QString::GET_ASCII怎么用?C++ QString::GET_ASCII使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QString
的用法示例。
在下文中一共展示了QString::GET_ASCII方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FileDialog
// opens a file dialog and returns true if a filename was selected. The compelete path is returned in filename (the buffer has to be big enough)
bool FileDialog(bool save_dialog, const char **filter, int num_filter, const char *caption, char *filename, int max_length)
{
QApplication *pApp = NULL;
if (qApp == NULL)
{
pApp = new QApplication(my_argc, my_argv);
}
char filter_str[1024];
char *fs = filter_str;
*fs = 0;
for (int i = 0; i < num_filter; i++)
{
if (i == num_filter - 1)
{
sprintf(fs, "%s (%s)", filter[(2*i)], filter[(2*i) + 1]);
fs += strlen(filter[(2*i)]) + strlen(filter[(2*i) + 1]) + 3;
}
else
{
sprintf(fs, "%s (%s);;", filter[(2*i)], filter[(2*i) + 1]);
fs += strlen(filter[(2*i)]) + strlen(filter[(2*i) + 1]) + 5;
}
}
*fs++ = 0;
if (save_dialog)
{
#if QT_VERSION >= 0x040000
QString s = QFileDialog::getSaveFileName(0, caption, NULL, filter_str);
#else
QString s = QFileDialog::getSaveFileName(QString(filename), filter_str, 0, "Save File Dialog", caption);
#endif
if (s.length() > 0)
{
strncpy(filename, s.GET_ASCII(), max_length);
if (pApp)
{
delete pApp;
pApp = NULL;
}
return true;
}
}
else
{
#if QT_VERSION >= 0x040000
QString s = QFileDialog::getOpenFileName(0, caption, NULL, filter_str);
#else
QString s = QFileDialog::getOpenFileName(QString(filename), filter_str, 0, "Open File Dialog", caption);
#endif
if (s.length() > 0)
{
strncpy(filename, s.GET_ASCII(), max_length);
if (pApp)
{
delete pApp;
pApp = NULL;
}
return true;
}
}
if (pApp)
{
delete pApp;
pApp = NULL;
}
return false;
}