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


C++ QString::GET_ASCII方法代码示例

本文整理汇总了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;
}
开发者ID:junaidnaseer,项目名称:ivt,代码行数:79,代码来源:GUIFactory.cpp


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