Results 1 to 4 of 4

Thread: To identify executable and other files in QT Application

  1. #1
    Join Date
    Jun 2009
    Location
    India
    Posts
    143
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question To identify executable and other files in QT Application

    Hi,

    I am using file dialog to open a particular folder or disk and see files in it which is of QT executable , text, image format files.

    How do i identify whether the opened file is executable or text or image file. As all you know , No file extension for linux files.

    ( My idea is if file opened is executable i will use Qprocess to execute it otherwise if it is text file i will use Qtextstream to read it .)









    I

  2. #2
    Join Date
    Jan 2010
    Posts
    73
    Thanks
    6
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: To identify executable and other files in QT Application

    You mention Linux. Do you know the file command? It will tell you a file type. Take a look here to see how it works

    http://linux.about.com/library/cmd/blcmdl1_file.htm

    Note, that this will identify links as links. On Windows, I believe that file extension is used.

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: To identify executable and other files in QT Application

    Linux uses mime types instead of extensions, so you would get the mime type for your file and if it says "executable", then you would use QProcess to execute it/etc.

    If you are unsure of the mime type used for a particular file, you can use the 'mimetype' command to figure it out. It's like 'file' but uses mime types instead of descriptions.

  4. #4
    Join Date
    Jan 2010
    Posts
    73
    Thanks
    6
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: To identify executable and other files in QT Application

    I use fedora, and it supports the file command, but not mimetype. I do have a high level of curiosity, however, so I poked around a bit.

    I am stating what I believe to be true with hopes that you will correct me if I am incorrect.

    • Gnome uses mime types to associate applications with files.
    • Gnome mime types use magic numbers to recognize the mime type.
    • There may be multiple associations for a specific type; for example, an OOo document may associate to an OOo document type and also to a ZIP file. This is, of course, as it should be.


    I looked at the gnome mime-type stuff in the file /etc/gnome-vfs-mime-magic

    Very interesting...

Similar Threads

  1. How to Create Executable file for my QT application
    By c_srikanth1984 in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2009, 04:02
  2. How to identify Num pad keys
    By sanjayshelke in forum Qt Programming
    Replies: 1
    Last Post: 2nd September 2008, 17:43
  3. identify QGraphicItem
    By avis_phoenix in forum Qt Programming
    Replies: 5
    Last Post: 24th September 2007, 06:16
  4. How to identify the process
    By vishesh in forum Qt Programming
    Replies: 1
    Last Post: 28th April 2007, 16:18
  5. How to identify event sender?
    By Caius Aérobus in forum Qt Programming
    Replies: 1
    Last Post: 29th November 2006, 10:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.