How to passing file path to app
-
Hi all,
i have one problem.
i have one application that runs in MAC and in windows.
i have associated file.xyz at this application.
in windows,when i double click on this file, the application start opening this file because it's passing his path
in MAC no,only start application but no start the file.i have set the associated of the file with my app but the file path no passing to main.
can you help me?
thanks
-
I don't know how mac associates file extensions with programs but it is different than windows. How did you "associate" the file with the app on the mac?
Honestly, this may require you understanding how the mac runs programs when associations are created. The only reason that your executable gets the file name on a windows machine is because of the windows registry. When you associate a file with a program on a windows machine, information is put into the registry that allows windows to execute your program using the shell command line. In other words it literally mimics sending arguments to your program as if it were typed out in a command line.
If the mac system has a different way of sending associated file information to its programs, this method will not work. Since I am not a mac user...I really don't know how it works on a mac.
-
[quote author="primem0ver" date="1411128705"]I don't know how mac associates file extensions with programs but it is different than windows. How did you "associate" the file with the app on the mac?
Honestly, this may require you understanding how the mac runs programs when associations are created. The only reason that your executable gets the file name on a windows machine is because of the windows registry. When you associate a file with a program on a windows machine, information is put into the registry that allows windows to execute your program using the shell command line. In other words it literally mimics sending arguments to your program as if it were typed out in a command line.
If the mac system has a different way of sending associated file information to its programs, this method will not work. Since I am not a mac user...I really don't know how it works on a mac.[/quote]
thak you for your reply
in MAC when you right click to file.xyz and "obtain info" you can associated one app at this file exstension.
in this way when i double click on all files with this extension app starts.
but not passing file path -
Hi,
What do you mean by "passing file path" ? Dropping a file on your application icon ?
-
OS X and Windows are different beasts. Have a look at "QFileOpenEvent":http://qt-project.org/doc/qt-5/QFileOpenEvent.html and the doc not that comes with it
-
[quote author="SGaist" date="1411385275"]OS X and Windows are different beasts. Have a look at "QFileOpenEvent":http://qt-project.org/doc/qt-5/QFileOpenEvent.html and the doc not that comes with it[/quote]
Hi SGaist,
thak you for your reply,
i have reimplemented this method
bool App::event(QEvent *event){
if(event->type()==QEvent::FileOpen){
QFileOpenEvent *fev=static_cast<QFileOpenEvent *>(event);
loadFile(fev->file());
return true;
}
return QApplication::event(event);
}in my application.
and now when i have the software started and i double click in associated file,the file is opened in my software.
but i f the program is close and i double click on file i have one error in report
QWidgets::X ....thanks
-
What error is that ?
-
[quote author="SGaist" date="1411418026"]What error is that ?[/quote]
Hi SGaist,
if i double click when the program is open,it's ok.
if i double click when the program is close,there is error.it seems like you can not create a interface....
the program cash next double click and not start
in he report ere is error in QWidget:X..thanks
-
What is the text provided with the error ?
-
Process: prova7 [1234]
Path: /Users/USER/Desktop/*/prova7.app/Contents/MacOS/prova7
Identifier: it.prova.prova
Version: ???
Code Type: X86-64 (Native)
Parent Process: launchd [349]
Responsible: prova7 [1234]
User ID: 501Date/Time: 2014-09-23 11:17:30.136 +0200
OS Version: Mac OS X 10.9.5 (13F34)
Report Version: 11
Anonymous UUID: EE450DB7-1A2F-12F0-73F3-7CA29136620BCrashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000028VM Regions Near 0x28:
-->
__TEXT 0000000100000000-000000010077d000 [ 7668K] r-x/rwx SM=COW /Users/USER/Desktop/*/prova7.app/Contents/MacOS/prova7Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 QtWidgets 0x0000000101378cca QWidget::x() const + 10
1 it.prova.prova 0x000000010007b319 AddMetroText(QString, QString, long*, long, QWidget*) + 57
2 it.prova.prova 0x000000010007b1f3 AddMetroLoad(QString, long*, long) + 99
3 it.prova.prova 0x0000000100135bc8 LoadRasterScn(char const*, bool) + 792
4 it.prova.prova 0x000000010010a739 ScnLoad(QString) + 505
5 it.prova.prova 0x000000010010e65b newEditScn(QString, bool) + 75
6 it.prova.prova 0x00000001001d4233 Application::openFile(QString) + 291
7 it.prova.prova 0x00000001001d80d2 Application::event(QEvent*) + 50
8 QtWidgets 0x000000010134d89c QApplicationPrivate::notify_helper(QObject*, QEvent*) + 300
9 QtWidgets 0x000000010135038d QApplication::notify(QObject*, QEvent*) + 6157
10 QtCore 0x0000000101f62a12 QCoreApplication::notifyInternal(QObject*, QEvent*) + 114
11 QtGui 0x000000010193259a QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) + 922
12 QtGui 0x00000001019225b0 QWindowSystemInterface::handleFileOpenEvent(QString const&) + 64
13 libqcocoa.dylib 0x0000000103c1b4b5 -[QCocoaApplicationDelegate application:openFiles:] + 437
14 com.apple.AppKit 0x00007fff893b00e5 __69-[NSApplication(NSAppleEventHandling) _handleAEOpenDocumentsForURLs:]_block_invoke + 1651
15 com.apple.AppKit 0x00007fff891abb80 __95-[NSPersistentUIManager restoreAllPersistentStateRegisteringAsReadyWhenDone:completionHandler:]_block_invoke538 + 37
16 com.apple.AppKit 0x00007fff891abb13 __78-[NSDocumentController(NSInternal) _autoreopenDocumentsWithCompletionHandler:]_block_invoke_2 + 140
17 com.apple.AppKit 0x00007fff891ab6fd -[NSDocumentController(NSInternal) _autoreopenDocumentsWithCompletionHandler:] + 746
18 com.apple.AppKit 0x00007fff891a3aa5 -[NSPersistentUIRestorer finishedRestoringWindowsWithZOrder:completionHandler:] + 1714
19 com.apple.AppKit 0x00007fff89018099 -[NSPersistentUIRestorer restoreStateFromRecords:usingDelegate:completionHandler:] + 2110
20 com.apple.AppKit 0x00007fff89017739 -[NSPersistentUIManager restoreAllPersistentStateRegisteringAsReadyWhenDone:completionHandler:] + 398
21 com.apple.AppKit 0x00007fff89016a36 -[NSApplication _reopenWindowsAsNecessaryIncludingRestorableState:registeringAsReady:completionHandler:] + 398
22 com.apple.AppKit 0x00007fff893af9e9 -[NSApplication(NSAppleEventHandling) _handleAEOpenDocumentsForURLs:] + 306
23 com.apple.AppKit 0x00007fff890162ab -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 450
24 com.apple.Foundation 0x00007fff8b22359a -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 294
25 com.apple.Foundation 0x00007fff8b22340d _NSAppleEventManagerGenericHandler + 106
26 com.apple.AE 0x00007fff88a2fe1f aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned int, unsigned char*) + 381
27 com.apple.AE 0x00007fff88a2fc32 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 31
28 com.apple.AE 0x00007fff88a2fb36 aeProcessAppleEvent + 315
29 com.apple.HIToolbox 0x00007fff8f3c6161 AEProcessAppleEvent + 56
30 com.apple.AppKit 0x00007fff890120b6 _DPSNextEvent + 1026
31 com.apple.AppKit 0x00007fff8901189b -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
32 com.apple.AppKit 0x00007fff8900599c -[NSApplication run] + 553
33 libqcocoa.dylib 0x0000000103c1815b QCocoaEventDispatcher::processEvents(QFlagsQEventLoop::ProcessEventsFlag) + 779
34 QtWidgets 0x0000000101384e64 QWidgetPrivate::show_helper() + 564
35 QtWidgets 0x00000001013858fd QWidget::setVisible(bool) + 1165
36 it.prova.prova 0x00000001001d9e60 main + 1584
37 it.prova.prova 0x0000000100004024 start + 52 -
What do you get from a run in the debugger ?