本文整理汇总了C++中QString::absolutePath方法的典型用法代码示例。如果您正苦于以下问题:C++ QString::absolutePath方法的具体用法?C++ QString::absolutePath怎么用?C++ QString::absolutePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QString
的用法示例。
在下文中一共展示了QString::absolutePath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getOpenFileNames
/* static */
QStringList QIFileDialog::getOpenFileNames (const QString &aStartWith,
const QString &aFilters,
QWidget *aParent,
const QString &aCaption,
QString *aSelectedFilter /* = 0 */,
bool aResolveSymlinks /* = true */,
bool aSingleFile /* = false */)
{
/* It seems, running QFileDialog in separate thread is NOT needed under windows any more: */
#if defined (VBOX_WS_WIN) && (QT_VERSION < 0x040403)
/**
* QEvent class reimplementation to carry Win32 API native dialog's
* result folder information
*/
class GetOpenFileNameEvent : public OpenNativeDialogEvent
{
public:
enum { TypeId = QEvent::User + 3 };
GetOpenFileNameEvent (const QString &aResult)
: OpenNativeDialogEvent (aResult, (QEvent::Type) TypeId) {}
};
/**
* QThread class reimplementation to open Win32 API native file dialog
*/
class Thread : public QThread
{
public:
Thread (QWidget *aParent, QObject *aTarget,
const QString &aStartWith, const QString &aFilters,
const QString &aCaption) :
mParent (aParent), mTarget (aTarget),
mStartWith (aStartWith), mFilters (aFilters),
mCaption (aCaption) {}
virtual void run()
{
QString result;
QString workDir;
QString initSel;
QFileInfo fi (mStartWith);
if (fi.isDir())
workDir = mStartWith;
else
{
workDir = fi.absolutePath();
initSel = fi.fileName();
}
workDir = QDir::toNativeSeparators (workDir);
if (!workDir.endsWith ("\\"))
workDir += "\\";
QString title = mCaption.isNull() ? tr ("Select a file") : mCaption;
QWidget *topParent = windowManager().realParentWindow(mParent ? mParent : windowManager().mainWindowShown());
QString winFilters = winFilter (mFilters);
AssertCompile (sizeof (TCHAR) == sizeof (QChar));
TCHAR buf [1024];
if (initSel.length() > 0 && initSel.length() < sizeof (buf))
memcpy (buf, initSel.isNull() ? 0 : initSel.utf16(),
(initSel.length() + 1) * sizeof (TCHAR));
else
buf [0] = 0;
OPENFILENAME ofn;
memset (&ofn, 0, sizeof (OPENFILENAME));
ofn.lStructSize = sizeof (OPENFILENAME);
ofn.hwndOwner = topParent ? topParent->winId() : 0;
ofn.lpstrFilter = (TCHAR *)(winFilters.isNull() ? 0 : winFilters.utf16());
ofn.lpstrFile = buf;
ofn.nMaxFile = sizeof (buf) - 1;
ofn.lpstrInitialDir = (TCHAR *)(workDir.isNull() ? 0 : workDir.utf16());
ofn.lpstrTitle = (TCHAR *)(title.isNull() ? 0 : title.utf16());
ofn.Flags = (OFN_NOCHANGEDIR | OFN_HIDEREADONLY |
OFN_EXPLORER | OFN_ENABLEHOOK |
OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST);
ofn.lpfnHook = OFNHookProc;
if (GetOpenFileName (&ofn))
{
result = QString::fromUtf16 ((ushort *) ofn.lpstrFile);
}
// qt_win_eatMouseMove();
MSG msg = {0, 0, 0, 0, 0, 0, 0};
while (PeekMessage (&msg, 0, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE));
if (msg.message == WM_MOUSEMOVE)
PostMessage (msg.hwnd, msg.message, 0, msg.lParam);
result = result.isEmpty() ? result : QFileInfo (result).absoluteFilePath();
//.........这里部分代码省略.........