Results 1 to 8 of 8

Thread: Opening files from a pinned Qt Application

  1. #1
    Join Date
    Sep 2015
    Posts
    25
    Thanks
    5

    Default Opening files from a pinned Qt Application

    I have pinned my Qt application to the taskbar

    However, I would like to open the application using external files, example lets say there is a jpeg file. I would like to be able to drag it onto the taskbar where the Qt app Icon is present and open the contents of the file in my App.

    How can that be accomplished?
    Any Qt classes specific to this purpose or should I use command line arguments?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Opening files from a pinned Qt Application

    You'll need to read the documentation of whatever system you have there that provides that.

    Maybe the system starts the application in a certain way or it jsut starts it and then devivers the drag to the first window or you need to register your program somehow for that kind of operation, etc.

    Cheers,

  3. #3
    Join Date
    Sep 2015
    Posts
    25
    Thanks
    5

    Default Re: Opening files from a pinned Qt Application

    Thanks for the response. But how am I supposed to make the Qt application understand that the file passed to it needs to be opened. Can it be done using an argument list?
    There needs to be some mechanism for the Qt application to understand that the file passed to it needs to be validated and opened right?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Opening files from a pinned Qt Application

    As I said: find out how the system handles these drags.
    There is nothing Qt specific here at all, the system does likely not distinguish which language an application is written in or which framework it uses, etc.

    Cheers,
    _

    P.S.: moving this to General Programming

  5. #5
    Join Date
    Sep 2015
    Posts
    25
    Thanks
    5

    Default Re: Opening files from a pinned Qt Application

    I really am unable to obtain the filename as an argument. If I may explain

    Qt Code:
    1. qDebug()<<QApplication::arguments().size();
    2. const QString toPass = argc > 1 ? QString(argv[1]) : QString();
    3. qDebug()<<toPass;
    To copy to clipboard, switch view to plain text mode 

    The above only gives 1 and an Empty String in the qDebug statements

    What I am trying to achieve is to be able to open the pinned files from the task bar of the pinned Qt Application over there and display their contents
    I do not wish to use QDesktopServices and open the files separately, rather use the file within the Qt application.

    Also, when using the pinned application, I do not see any debug lines getting printed in the Qt console, where can I look for the same?

    Sorry for the trouble and Thanks
    Last edited by newtoQ_s; 23rd November 2015 at 13:51.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Opening files from a pinned Qt Application

    Quote Originally Posted by newtoQ_s View Post
    I really am unable to obtain the filename as an argument. If I may explain

    Qt Code:
    1. qDebug()<<QApplication::arguments().size();
    2. const QString toPass = argc > 1 ? QString(argv[1]) : QString();
    3. qDebug()<<toPass;
    To copy to clipboard, switch view to plain text mode 

    The above only gives 1 and an Empty String in the qDebug statements
    How did you call the application?
    Did you pass an argument?

    Quote Originally Posted by newtoQ_s View Post
    What I am trying to achieve is to be able to open the pinned files from the task bar of the pinned Qt Application over there and display their contents
    We've already covered that.

    Quote Originally Posted by newtoQ_s View Post
    I do not wish to use QDesktopServices and open the files separately, rather use the file within the Qt application.
    QDesktopServices is for delegating file opening to other applications, so not relevant here.

    Quote Originally Posted by newtoQ_s View Post
    Also, when using the pinned application, I do not see any debug lines getting printed in the Qt console, where can I look for the same?
    Your operating system might have a logging facility and Qt might have been built with support for that and log to this factility.
    If you are unsure, maybe log to a file.

    Cheers,
    _

  7. #7
    Join Date
    Sep 2015
    Posts
    25
    Thanks
    5

    Default Re: Opening files from a pinned Qt Application

    I am unable to understand as to how one can pass the pinned File on a Qt application as an argument, if that is relevant at all.

    example.png

    I want to be able to open pinned files in a similar way from the Qt application that is pinned to the taskbar.
    I am unable to understand the mechanism of how one can pass these files to the Qt application in order to be used within the application.

    The main issue is how one can make a pinned file be passed as an argument to the Qt application?
    All I am able to see is that there is a pinned file menu and on clicking the file the QApplication opens (Windows) but what I am trying to achieve is obtain the file's name in the process of opening the pinned file for use in the QApplication.
    Last edited by newtoQ_s; 24th November 2015 at 08:50.

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Opening files from a pinned Qt Application

    Quote Originally Posted by anda_skoa View Post
    You'll need to read the documentation of whatever system you have there that provides that.
    Quote Originally Posted by anda_skoa View Post
    As I said: find out how the system handles these drags.
    And a third time:
    find the system's developer documentation and research how this mechanism works.

    Cheers,
    _

Similar Threads

  1. Replies: 2
    Last Post: 7th August 2013, 17:51
  2. Implementing pinned menu items
    By wssddc in forum Qt Programming
    Replies: 1
    Last Post: 30th July 2013, 06:16
  3. opening PPT files in Qt
    By jay in forum Qt Programming
    Replies: 5
    Last Post: 14th May 2009, 13:20
  4. QDesktopServices::openUrl() not opening files in set path
    By been_1990 in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2009, 19:34
  5. Replies: 7
    Last Post: 20th December 2007, 10:56

Tags for this Thread

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.