Open the file in the same instance of the application



  • I have written an application in Qt where it reads an xml file (file with diagrams and scene). I had registered the extension to open with my application on double clicking in Windows.
    This file would open a new tab (which is a feature of the application. So I could open several files together in tabs. This behaviour seemed to have disappeared. Now each time I double click on the file it opens a new instance. The difference I noticed when I upgraded to 5.7.0 (Sorry but during the several upgrades might have missed which upgrades had this broken).

    Not sure if this is a setting in Qt which can be triggered back. Windows OS questions seem like this has to be baked within the application since the OS does not handle this.

    If I need to provide more information please let me know. I hope I have framed the question correctly.

    Thanks in advance.


  • Moderators

    @vivian Are you sure it was working before as you described?
    Actually you have to implement this in your app. I don't think Qt ever supported this without additional implementation.
    There is something you can use for this: https://github.com/qtproject/qt-solutions/tree/master/qtsingleapplication



  • @vivian Yea that should never have worked without you adding in support for it.

    You need a singleton application like @jsulm posted. Then you need to handle getting the filename via the shell and code it to open a new tab.

    That's really odd that ever worked before. It's certainly not part of Qt.



  • @ambershark @jsulm Thank you for your input. I am trying my best to get the oldest version of my application to confirm that.
    I will keep you posted on this. Hoping to add this as part of the application.



  • @vivian The good news is it's quite easy to add using that qtsingleapplication @jsulm mentioned.

    Then you just need to deal with the extra tab being opened which should also be quite trivial.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.