Arguments in Mac OS X - MacRumors Forums
Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 21, 2011, 09:43 PM   #1
syamamoto
macrumors newbie
 
Join Date: Dec 2011
Location: Tokyo, Japan
Arguments in Mac OS X

I am using Qt (Nokia) with X-Code. Once coded, it works with Windows, Linux, and in Mac OS X. However, double-clicking in the Finder or drag-and-dropping from the Finder works in a different way.

I supposed that the name of the file that was double-clicked or dropped is sent by the arguments in main( ) function such as:
int main( int argc, char *argv[] )
The name is usually stored in argv[1]. Alternatively, it is possible to get argument strings by QCoreApplication::arguments( ) as a QStringList. In Mac OS X, Finder seems to send some message in a fashon completely different form the ordinary methods.

Could someone tell me how to get the name of the data files that are sent from Finder by double-clicking or by dropping in Mac OS X. I am not using Objective C because it just works only with Mac OS X.

Thank you.

SYamamoto
syamamoto is offline   0 Reply With Quote
Old Dec 21, 2011, 11:37 PM   #2
admanimal
macrumors 68040
 
Join Date: Apr 2005
Normally the application will call a method in it's delegate to tell it to open the file. It's not passed via argv.
admanimal is offline   0 Reply With Quote
Old Dec 22, 2011, 11:31 AM   #3
chown33
macrumors 603
 
Join Date: Aug 2009
You should probably ask your question on a forum that specializes in Qt.


I googled the following search terms:
qt drag and drop
qt drag and drop files

The results show the basic Qt DnD reference doc, a mention of XDND protocol, and a nearly identical question from 2005:
http://www.qtforum.org/article/15340...drop-file.html

which contains a link to this:
http://doc.trolltech.com/3.3/quridrag.html

I didn't spend more than about 2 minutes doing these searches. The important thing is to confine the search to Qt, since a correct answer must use only portable Qt features or capabilities. Asking how to do it on a Mac is misguided if the result needs to be portable.
chown33 is offline   0 Reply With Quote
Old Dec 22, 2011, 06:57 PM   #4
syamamoto
Thread Starter
macrumors newbie
 
Join Date: Dec 2011
Location: Tokyo, Japan
Mac specific issue

Quote:
Originally Posted by chown33 View Post
You should probably ask your question on a forum that specializes in Qt.
Than you very much for your response. I am routinely using drag-and-drop mechanism in Qt and it works fine with Windows and Linux. I am familiar with the Qt reference pages you told me.

When a file is dropped on the application icon, the application starts at the enter point main( argc, argv ). In Windows and Linux, argv[1] contains the name of dropped file. This is not the case with Mac OS X. When an application in Mac is executed by a shell, it is possible to send the data file name to be opened but then it is not possible to send the file name from Finder to the shell.

Otherwise, Qt provides QCoreApplication::arguments( ) function and it also works with Windows and Linux. However, in Mac OS X, it just returns an empty string.

Therefore, what I want to know is simple. The method to know the file name dropped from Finder in Mac OS X. Probably this is not the problem of Mac OS X and I should find out the method in Qt functions. I tried to find out, but I could not get useful information. I rather considered that I have to solve this problem by Mac-specific method as is shown in
http://developer.qt.nokia.com/doc/qt...fferences.html

Thank you again.

syamamoto

Last edited by maflynn; Dec 22, 2011 at 07:20 PM.
syamamoto is offline   0 Reply With Quote
Old Dec 22, 2011, 07:20 PM   #5
chown33
macrumors 603
 
Join Date: Aug 2009
I googled for:
qt mac files

One of the top results was this:
http://doc.qt.nokia.com/qq/qq12-mac-events.html

After reading the first few paragraphs, you should probably skip the rest of the article and scroll down to the bottom to read about the QFileOpenEvent class.
chown33 is offline   0 Reply With Quote
Old Dec 22, 2011, 10:40 PM   #6
syamamoto
Thread Starter
macrumors newbie
 
Join Date: Dec 2011
Location: Tokyo, Japan
Arguments when a file is dropped

Quote:
Originally Posted by chown33 View Post
I googled for:
qt mac files
Thank you very much. This information is what I have been looking for. I wonder why I could not find out the page!

I appreciate your kindness.

syamamoto

Last edited by balamw; Dec 23, 2011 at 05:02 AM. Reason: fixed quote
syamamoto is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
NSRegularExpression to capture C function arguments? ArtOfWarfare Mac Programming 13 Jun 17, 2013 11:17 PM
Accepting arguments of multiple types? moonman239 iPhone/iPad Programming 8 Jun 5, 2013 01:35 AM
Resolved: variable arguments help (Cocoa format string) ArtOfWarfare Mac Programming 1 May 1, 2013 02:22 AM
Calling applescript from objective c code with arguments Jitin Jindal Mac Programming 2 Mar 4, 2013 11:03 AM

Forum Jump

All times are GMT -5. The time now is 03:47 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC