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. Purple Error in Widget Project
Forum Updated to NodeBB v4.3 + New Features

Purple Error in Widget Project

Scheduled Pinned Locked Moved General and Desktop
17 Posts 2 Posters 5.1k 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.
  • F Offline
    F Offline
    Flurite
    wrote on last edited by
    #5

    Yeah, the errors are generated in that file, but you cannot save changes to that file.

    I will try and fix up that memory leak you mentioned. Thanks.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #6

      True, you can't save changes to that file, but those items are generated from your .ui file. Make sure that in the .ui file that any signal/slot connections you are making are pointing at the right objects.

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Flurite
        wrote on last edited by
        #7

        The arrows are all pointing at the MainWindow (or Clock_Application), so this is what made me wonder whether you can only declare slots in the MainWindow (or Clock_Application) class.

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

          There's nothing magical about MainWindow or Clock_Application or anything like that. There's just a connection being made somewhere (looks like in your .ui file) which is still expecting the timer_Start() slot (etc.) to be in the old location. Just moving the slot definition isn't enough to make the .ui file look point to the right place.

          What are you doing in the clock_application.ui file which calls timer_Start()? What triggers timer_Start() to be called?

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

          1 Reply Last reply
          0
          • F Offline
            F Offline
            Flurite
            wrote on last edited by
            #9

            timer_Start() is triggered by a click of a button in the widget application. The button is a simple QPushButton.

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

              Where is the connection made?

              Software Engineer
              My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

              1 Reply Last reply
              0
              • F Offline
                F Offline
                Flurite
                wrote on last edited by
                #11

                When you say "connection" do you refer to my connect() function? If so, here it is:

                @
                void Stopwatch::timer_Start()
                {
                stopwatchTimer = new QTimer();
                connect(stopwatchTimer, SIGNAL(timeout()), this, SLOT(timer_changeTime()));
                stopwatchTimer->start(1000);
                }
                @

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

                  No. What makes the button call timer_Start(). How do you tell it to do this?

                  Software Engineer
                  My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    Flurite
                    wrote on last edited by
                    #13

                    I use that one menu in Qt Designer that allows you to draw blue/red arrows. I then create a new slot, and call it "timer_Start()", and I believe, this automatically connects the clicked() signal and the timer_Start() slot.

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mlong
                      wrote on last edited by
                      #14

                      The arrows need to point to Stopwatch, not Clock_Application, if the slots are defined in Stopwatch.

                      Behind the scenes, those arrows translate to a "connect()" call in the ui_clock_application.h file.

                      Software Engineer
                      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                      1 Reply Last reply
                      0
                      • F Offline
                        F Offline
                        Flurite
                        wrote on last edited by
                        #15

                        How do I get it to "point" to Stopwatch? Stopwatch is just a class. It does not really refer to any widget.

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mlong
                          wrote on last edited by
                          #16

                          Ah. Good point. In that case, I'd say that there shouldn't be any arrows anywhere, and that you should make the connection in code.

                          Edit to add:

                          Alternately, you could keep "proxy" slots in your Clock_Application widget, and from within those slots just call the slots in Stopwatch.

                          That is to say:
                          @
                          class Clock_Application ...
                          {
                          Q_OBJECT
                          ...
                          public slots:
                          void timer_Start() { m_stopwatch->timer_Start(); } // just "pass through" to your Stopwatch class. (Remember that slots are just plain old methods too, and can be directly called like any other method.)
                          ...
                          private:
                          Stopwatch *m_stopwatch;
                          };
                          @

                          Software Engineer
                          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                          1 Reply Last reply
                          0
                          • F Offline
                            F Offline
                            Flurite
                            wrote on last edited by
                            #17

                            Hmm.. now I am receiving a strange error:

                            multiple definition of ui
                            first defined here
                            collect2: Id returned 1 exit status

                            The lines in where the errors occur do not seem to be in my project, but in other files.. possibly library files? It's also strange, because I have defined my own ui just previously, and am wondering what is causing it now.

                            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