I mean this:
If I have a program called A,and I set A as the default program for opening mp3 files in Linux,how can my program know it when the user opens a mp3 file in Linux desktop environment?
I mean this:
If I have a program called A,and I set A as the default program for opening mp3 files in Linux,how can my program know it when the user opens a mp3 file in Linux desktop environment?
This has nothing to do with your application (Qt). It's a setting of your desktop environment and you have to set the setting there.
@Lykurg: i think that what he meant to ask is: how the Linux OS is sending the file (name and path) to the associated qt application so that the programmer can open that particular file. (if that was the question - i don't know the answer )
berlinud (16th September 2010)
Although suffixes will mostly do the job, a more correct way is to use mime types.
edit: ignore, I read the previous post wrong
Last edited by tbscope; 16th September 2010 at 15:44.
You are definitely right Zlatomir!
That is exactly what I mean.
Would you mind explaining it a little more detail?
Since I am new in Linux programming.
what data will be transfered to me as the argument of main?
is that an absolute path?
Here is a test project:
Qt Code:
#include <QtGui> #include <QStringList> int main(int argc, char** argv){ QTextEdit t; QStringList l = qApp->arguments(); // qApp is a macro to QApplication instance and the arguments() returns a QStringList with the arguments t.setText(l.join("\n")); t.show(); return a.exec(); }To copy to clipboard, switch view to plain text mode
LE: I'm on win now and the first one is the full path and name of the application
Last edited by Zlatomir; 16th September 2010 at 16:15.
berlinud (16th September 2010)
I tested it.
$ ./TestForMainArg ggg fff fff fff fff
the result is this:
./TestForMainArg
ggg
fff
fff
fff
fff
create a text file rename it with .bla extension and create the association and see how the actual double click acts. (it should send the path too)
berlinud (16th September 2010)
When I turn the test program as the default program for mp3;
it shows that the arguments are transfered into the program as absolute path.
yes you are right
Bookmarks