Results 1 to 13 of 13

Thread: Opening documents on Windows

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Opening documents on Windows

    Hi,

    On Mac, you can open a document directly from the finder (see Opening_documents_in_the_Mac_OS_X_Finder )
    It relies on a QFileOpenEvent class which is currently supported for Mac OS X only.
    How can I get an equivalent on windows ? (i.e. the ability to drop a file on the application icon to open it).
    Thanks in advance for any help.
    --
    Dom

  2. #2
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Opening documents on Windows

    If all you want on Windows is to be able to drag and drop one or several files on your application, then you need to handle the arguments passed to your Qt application. Just try the following:

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "mainwindow.h"
    3. #include <QMessageBox>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication a(argc, argv);
    8.  
    9. QMessageBox::information(NULL, "Arguments:", a.arguments().join(" | "));
    10.  
    11. MainWindow w;
    12. w.show();
    13.  
    14. return a.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    131
    Thanks
    11
    Thanked 16 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Opening documents on Windows

    I think he wants to register a file type for his application. You can do this with your installer. E.g. WIX or
    NSIS or do it manual by modifying the registry.

  4. #4
    Join Date
    Jul 2010
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Opening documents on Windows

    Thanks a lot !
    That's exactly what I need

    Thanks a lot !
    That's exactly what I need

    I think he wants to register a file type for his application. You can do this with your installer. E.g. WIX or NSIS or do it manual by modifying the registry.
    That's another problem. I just want to support files dropped on the application icon.
    (and it works now using the application arguments())

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Opening documents on Windows

    Quote Originally Posted by fober View Post
    Thanks a lot !
    That's exactly what I need

    Thanks a lot !
    That's exactly what I need



    That's another problem. I just want to support files dropped on the application icon.
    (and it works now using the application arguments())
    Note that this is a different situation from the one you describe in your original post. Mac allows you to drop a document on an icon of an application that is already running, what you mean is a situation when you want to launch a new instance of your application passing it the document to open.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Jul 2010
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Opening documents on Windows

    Note that this is a different situation from the one you describe in your original post. Mac allows you to drop a document on an icon of an application that is already running, what you mean is a situation when you want to launch a new instance of your application passing it the document to open.
    You're right ! Let's say that I get half of the desired behavior (not so bad )
    Any tip on getting the second half (dropping a file when the application is already running) is welcome !

    However, I don't think that's usual on Windows : most of the time, when you drag a file to the tasks bar over a running application, it brings the application window to foreground and you can next drop the file to the window, which has cross-platform support in Qt. (note that I'm not an expert in windows)

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Opening documents on Windows

    Quote Originally Posted by fober View Post
    You're right ! Let's say that I get half of the desired behavior (not so bad )
    Any tip on getting the second half (dropping a file when the application is already running) is welcome !
    What do you want to drop it on? There is no direct Windows equivalent of what's available for Mac.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Jul 2010
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Opening documents on Windows

    What do you want to drop it on?
    A document file, actually describing the content of a window. For more information about what I'm doing, see the INScore project.

    There is no direct Windows equivalent of what's available for Mac.
    I guess so. That's why the second half is no so important. And I think it's better to stick to the platform standard behavior.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Opening documents on Windows

    Quote Originally Posted by fober View Post
    A document file, actually describing the content of a window. For more information about what I'm doing, see the INScore project.
    I don't understand what "dropping a file on a document file" means.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Jul 2010
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Opening documents on Windows

    I don't understand what "dropping a file on a document file" means.
    Sorry ! It looks like I've not been very clear. I was speaking about dropping a document on the application icon, and this document is basically describing the content of a scene.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Opening documents on Windows

    Quote Originally Posted by fober View Post
    I was speaking about dropping a document on the application icon, and this document is basically describing the content of a scene.
    On the application icon while the application is running? Again, Windows doesn't have a concept of such a thing...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #12
    Join Date
    Jul 2010
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Opening documents on Windows

    On the application icon while the application is running? Again, Windows doesn't have a concept of such a thing...
    I know, that's why I feel satisfied with half of the Mac OS behavior (see above)

Similar Threads

  1. Creating documents from Qt
    By GrahamLabdon in forum Qt Programming
    Replies: 16
    Last Post: 26th April 2010, 10:00
  2. Opening windows on different x screens
    By Shades in forum Qt Programming
    Replies: 0
    Last Post: 29th June 2009, 09:41
  3. Can Qt handle pdf documents???
    By webquinty in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 23rd March 2009, 15:16
  4. Opening text file fails after autostartup on windows
    By yogourta in forum Qt Programming
    Replies: 2
    Last Post: 18th October 2008, 03:52
  5. opengl documents
    By neomax in forum General Discussion
    Replies: 1
    Last Post: 20th November 2006, 07:27

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
  •  
Qt is a trademark of The Qt Company.