Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFileOpenEvent
Forum Updated to NodeBB v4.3 + New Features

QFileOpenEvent

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ARASHz4
    wrote on last edited by
    #1

    hi
    i want open a file, double clicking on an file in the Finder on OS X
    in mac 'QApplication::arguments()' don't work!
    i need a good example for QFileOpenEvent

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Because as the name suggests it's an event. The file name is not added to the argument list. First thing, did you configure your application to handle files opened that way ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Because as the name suggests it's an event. The file name is not added to the argument list. First thing, did you configure your application to handle files opened that way ?

        A Offline
        A Offline
        ARASHz4
        wrote on last edited by ARASHz4
        #3

        @SGaist hi
        how to configure application to handle files?
        i add some suffix like .png to Info.plist in app/Contents, this is configure application?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Please share your .plist file

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          A 1 Reply Last reply
          0
          • SGaistS SGaist

            Please share your .plist file

            A Offline
            A Offline
            ARASHz4
            wrote on last edited by ARASHz4
            #5

            @SGaist this is my Info.plist

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              That looks OK. You should have the event sent to your application if you e.g. drop a supported file on the Dock Icon of your application.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              A 1 Reply Last reply
              0
              • SGaistS SGaist

                That looks OK. You should have the event sent to your application if you e.g. drop a supported file on the Dock Icon of your application.

                A Offline
                A Offline
                ARASHz4
                wrote on last edited by
                #7

                @SGaist What event?
                Please show me an example

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  QFileOpenEvent.

                  class MyApplication : public QApplication
                  {
                  public:
                      MyApplication(int &argc, char **argv, int flags = ApplicationFlags)
                          : QApplication(argc, argv, flags)
                      {
                  
                      }
                  
                      bool event(QEvent *event)
                      {
                          if (event->type() == QEvent::FileOpen) {
                              QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(event);
                              qDebug() << "File open" << openEvent->file();
                          }
                  
                          return QApplication::event(event);
                      }
                  
                  };
                  

                  Use it in place of QApplication.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved