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. Calling function from reimplemented QApplication / notify
Forum Updated to NodeBB v4.3 + New Features

Calling function from reimplemented QApplication / notify

Scheduled Pinned Locked Moved General and Desktop
13 Posts 3 Posters 3.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.
  • sierdzioS Offline
    sierdzioS Offline
    sierdzio
    Moderators
    wrote on last edited by
    #2

    Your linker does not see TouchEventForTCO in the libraries/ objects it was given. You probably should include the library where that method comes from.

    (Z(:^

    1 Reply Last reply
    0
    • McLionM Offline
      McLionM Offline
      McLion
      wrote on last edited by
      #3

      Yeah, that's what I know as well so far.
      TouchEventForTCO is in class QTGUI_MainWindow and the code snippet posted before in in the qtgui_mainwindow.h where QTGUI_MainWindow is defined. The function itself is in qtgui_mainwindow.cpp and I added an extern to the qtgui_mainwindow.h.

      I just dont know what is wrong or incomplete ?!?

      1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #4

        Again: the error you are getting does not come from the compiler: so all the C++ includes are fine. The linker does not see the (already compiled) object code, which means something is wrong in your build setup. Either a library not included, or qtgui_mainwindow.o is not present.

        (Z(:^

        1 Reply Last reply
        0
        • McLionM Offline
          McLionM Offline
          McLion
          wrote on last edited by
          #5

          Hmmm...
          If I only comment out the call
          @TouchEventForTCO(event->type(), cursorPos.rx(), cursorPos.ry());@

          everything builds and runs perfect.
          qtgui_mainwindow.o is present.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            topse
            wrote on last edited by
            #6

            run qmake?

            1 Reply Last reply
            0
            • McLionM Offline
              McLionM Offline
              McLion
              wrote on last edited by
              #7

              qmake didn't help.

              1 Reply Last reply
              0
              • McLionM Offline
                McLionM Offline
                McLion
                wrote on last edited by
                #8

                Anybody else an idea what I have set wrong to have the linker giving this error?

                1 Reply Last reply
                0
                • McLionM Offline
                  McLionM Offline
                  McLion
                  wrote on last edited by
                  #9

                  Solved it. Changed call to:
                  @QTGUI_MainWindow::TouchEventForTCO(event->type(), cursorPos.rx(), cursorPos.ry()); @
                  and made TouchEventForTCO() static and public.

                  I don't know if this is the "correct" way .. however, it works :)
                  Thanks everybody for their help.

                  1 Reply Last reply
                  0
                  • McLionM Offline
                    McLionM Offline
                    McLion
                    wrote on last edited by
                    #10

                    Too happy too soon ;)

                    I can now call TouchEventForTCO() and also read the arguments, copy them ... whatever. However, as soon as I call another function from inside TouchEventForTCO() I get back to the same problem and I get:
                    @..\src\qtgui_mainwindow.cpp: In static member function 'static void QTGUI_MainWindow::TouchEventForTCO(int, int, int)':
                    ..\src\qtgui_mainwindow.cpp:1851: error: cannot call member function 'void QTGUI_MainWindow::PrepareForTCO(QByteArray*)' without object
                    @
                    I somehow cant believe that I have to make every function public that need to be called down the line.
                    How do I solve this the correct way in C++?

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      topse
                      wrote on last edited by
                      #11

                      You are really not having Qt-Trouble, bu C++ trouble...

                      Check C++ - tutorials, what static means pls :-/ In short: Static-Functions are called without an object. So you cant call non-static-functions from within a static function, because non-static function need an object.

                      "static functions" in object oriented world is comparable to "global functions" in functional world, but static functions belong to a classes namespace.

                      Best Regards.

                      1 Reply Last reply
                      0
                      • McLionM Offline
                        McLionM Offline
                        McLion
                        wrote on last edited by
                        #12

                        You're right. It's a C++ issue, not Qt.
                        So, making TouchEventForTCO() static and public is not the correct way, I assume. If not, how do I call QTGUI_MainWindow::TouchEventForTCO from the MyApplication::notify in the other class then (see code snippets above)?

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          topse
                          wrote on last edited by
                          #13

                          I cant really tell you with that little code-examples... regarding your very first post it seems that you have not implemented your constructor. Another C++-thing...

                          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