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. [SOLVED][Drag'n Drop] QMainWindow and linking error
Qt 6.11 is out! See what's new in the release blog

[SOLVED][Drag'n Drop] QMainWindow and linking error

Scheduled Pinned Locked Moved General and Desktop
12 Posts 2 Posters 8.0k 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.
  • G Offline
    G Offline
    giesbert
    wrote on last edited by
    #2

    Hi Max13,

    can you please also show your cpp file?
    I think you perhaps have forgotten the implementation?

    Nokia Certified Qt Specialist.
    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Max13
      wrote on last edited by
      #3

      Hi,
      I've let the implementation away, I was testing.
      Because I've noticed that GCC can complain about missing definition, but not for missing implementation.

      Isn't it? =P

      We all have started by asking questions. Then after some time, we can begin answering them.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #4

        You must at least have empty functions.
        They needn't be filled but the function body is a must.

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Max13
          wrote on last edited by
          #5

          Ok, I'll do it.
          BTW, do you know if the implementation explained in the FAQ, if I Want to be able to drag-n-drop from the desktop to my app? (since it's not a part of my app =/ )

          ?
          Thanks for tour help!

          We all have started by asking questions. Then after some time, we can begin answering them.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #6

            Hi,

            I did that once and could dig a bit for it, but that takes time.
            In general, you have to do it like in the docs, I never used this faq, only the online docs.

            You can start at the "examples for drag'n'drop":http://doc.qt.nokia.com/4.7/examples-draganddrop.html

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #7

              Hi,

              I created a small wiki article on how to open files from drag operations inside a QMainWindow:

              "wiki article":http://developer.qt.nokia.com/wiki/Drag_and_Drop_of_files

              On windows, I would connect that with the "assignment of file types":http://developer.qt.nokia.com/wiki/Assigning_a_file_type_to_an_Application_on_Windows

              Hope that helps a bit.

              Have fun.

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Max13
                wrote on last edited by
                #8

                Hi,

                Thank you a lot !
                I've added empty functions, and it worked (:/).

                Thank, I saw your Wiki, GREAT !
                But something wrong (perhaps from me, perhaps from Qt)

                @void MainWindow::dropEvent(QDropEvent *de)
                {
                const QMimeData * mimeData = de->mimeData();

                if (mimeData->hasUrls())
                {
                qDebug() << mimeData->urls(); // Line 10
                }
                }@

                I have tons of errors :/
                Line 10 above is line 10 here: http://pastebin.com/89k8G0aq

                Thank you for your help anyway :)

                We all have started by asking questions. Then after some time, we can begin answering them.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #9

                  Hi Max,

                  I'm not sure, whether QList<QUrls> is able to be streamed to qDebug.
                  If you read the wiki, you will find I use the local paths of the urls, so like this:

                  @
                  void DocumentWindow::dropEvent(QDropEvent* event)
                  {
                  const QMimeData* mimeData = event->mimeData();

                  // check for our needed mime type, here a file or a list of files
                  if (mimeData->hasUrls())
                  {
                      QList<QUrl> urlList = mimeData->urls();
                  
                      // extract the local paths of the files
                      for (int i = 0; i < urlList.size() && i < 32; ++i)
                      {
                          qDebug() << urlList.at(i).toLocalFile&#40;&#41;;
                      }
                  }
                  

                  }
                  @

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    Max13
                    wrote on last edited by
                    #10

                    Sorry...

                    Usually, i'm less dumb ^^

                    I have the same errors with this line: @QList<QUrl> urlList = mimeData->urls();@

                    So:
                    @void MainWindow::dropEvent(QDropEvent *de)
                    {
                    const QMimeData * mimeData = de->mimeData();

                    if (mimeData->hasUrls())
                    {
                    QList<QUrl> urlList = mimeData->urls();
                    }
                    }@

                    Is the error between my chair and my computer ? =P

                    We all have started by asking questions. Then after some time, we can begin answering them.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      giesbert
                      wrote on last edited by
                      #11

                      [quote author="Max13" date="1302617263"]Is the error between my chair and my computer ? =P[/quote]

                      Perhaps :-)

                      I saw you are using Qt 4.7.3?
                      I only tried with 4.7.2... on windows
                      There I had no problems.

                      Are you missing some includes? The error talks about forward declarations...

                      @
                      #include <QtCore/QUrl>
                      #include <QtCore/QList>

                      @

                      Nokia Certified Qt Specialist.
                      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        Max13
                        wrote on last edited by
                        #12

                        Hi !
                        Sorry for having made the dead.

                        I've reinstalled the libs, did everything you explained, and...

                        IT WORKS GREAT !!

                        Thank you a lot for you patience.
                        I'm done now :)

                        We all have started by asking questions. Then after some time, we can begin answering them.

                        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