Qt World Summit: Submit your Presentation

Open with...

  • Hi! I have a program that works with files. How can I open files on my computer with my program using windows-context menu?

  • Lifetime Qt Champion


    What OS are you talking about ?
    In any case, it's likely something you'll have to setup at installation time.

  • @SGaist
    I want do it on Windows.
    Please, tell more about installation

  • @GRUB_666

    Do you want to use the context menu inside your program window or everywhere?

    Inside your app, you can use QContextMenuEvents from a QMenu.
    To use it anywhere else, you have to register the action on your OS (set Windows Registry Keys)

    This shows how to do it manually. You have to create the REG_KEYs with your app, and then define actions what will happen, if you open file "test.abc" with your app

  • or what you can do is to make right click on the file that you want to open with your program and then to properties and then change the default open with and set there your program then click on Apply and Ok - depending on windows version that you use you can also edit the extension and put a path to your program there to handle that extension

  • @arsinte_andrei

    Depending on the file extension, it may work (if you have custom extensions), but if you have "basic extensions" like .txt, jpg it's better to not set your app as default program for all files with this type. Unless you created e.g. a new image viewer (to show / edit png files) to replace the windows app and you only want to use your app to open this :)

Log in to reply