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. QtCreator UI-designer suddenly fails to add/find slots
Forum Updated to NodeBB v4.3 + New Features

QtCreator UI-designer suddenly fails to add/find slots

Scheduled Pinned Locked Moved General and Desktop
14 Posts 10 Posters 20.2k 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.
  • D Offline
    D Offline
    DerManu
    wrote on last edited by
    #3

    Maybe this will give you some hope: After a week or so of creating the slots manually for that specific ui file (by naming the slots appropriately, they get automatically connected to the respective signals), I tried it again via the QtCreator context menu, and it worked again. Still no idea what caused it.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      raato
      wrote on last edited by
      #4

      Thanks for the tip about naming slots appropriately, that helps! Let's hope my project too will be magically fixed at some point. I tried taking .ui file from old backup where "go to slot" still works, but that didn't help. Also compared .cpp and .h files - no differences that should have anything to do with this. Very strange.

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

        Just stumbled onto this post and I have some further information that might provide some insight.

        Just for experimentation, I tested passing "ui" from my mainwindow to another class I created. That worked fine, then for fun, I right clicked on a widget on mainwindow.ui, clicked "Go to slot", chose a signal, and the slot got created in my secondary class (usermanager.cpp). I didn't expect that at all so I removed the passing of ui to usermanager.cpp, and then I began to get the same error posted above when trying to create the slot via right click. I found this post "error creating slot...":http://www.qtcentre.org/threads/33120-Widget-Go-To-Slot-causes-The-class-definition-of-Ui-could-not-be-found , remembered I was still including ui_mainwindow.h in my usermanager.cpp class unecessarily, and when I removed it I was then able to add a slot without error to mainwindow.cpp.

        mtnbiker

        1 Reply Last reply
        0
        • R Offline
          R Offline
          raato
          wrote on last edited by
          #6

          Thanks, now I get it. I too have added '#include "ui_mainwindow.h"' to few other classes, and passed pointer to mainwindow to them. This way I can access mainwindow widgets directly from those other classes. This is not how to design proper applications, I know, but I'm UI-prototyping here.

          So apparently these other '#include "ui_mainwindow.h"'s confuse the designer. Have to check if there is some workaround for this (other than fixin my code, that is, hehe).

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mtnbiker
            wrote on last edited by
            #7

            I'm trying to redesign the one Qt project I've done to make it more OO friendly - I did most of the work in mainwindow.cpp - and in order to get around accessing the widgets from other classes I'm doing all my data/model processing in the new classes and leaving all the ui work in mainwindow which leaves me with having to pass data in as parameters.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kottalovag
              wrote on last edited by
              #8

              Hi guys, I just met this very same problem. I was refactoring my 3-year old project to c++11. I didn't like my MainWindow class to hold a bare Ui::MainWindow* ui rawpointer deleting it in the destructor. I tried to wrap it into std::unique_ptrUi::MainWindow and cleaned the destructor (for me it seems c++11 encourages us to clean out any ownership-handling responsibilities from destructors). Anyway, when I tried to go to a previously setup slot, I met this problem, too. I changed back the raw-ptr ui, (kept the unique_ptr buddy as well, haha) and it worked again.

              S 1 Reply Last reply
              1
              • K Offline
                K Offline
                Karolis B.
                wrote on last edited by
                #9

                I'm having this problem as well and no idea how to solve it. Has anybody found a solution yet?

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  fiestaman
                  wrote on last edited by
                  #10

                  I've the same here, I fixed it. For any reason, on moving my window class from a projet to other, it has changed the ui #include from the header file to the .cpp file. So i've deleted the include from the cpp and I put it into my window .h file and it's working again.

                  I had a problem with the sensitive case of the header files name. Then, just clean all, rebuild all, go to slot, there are a error jet, rebuild all again and it works.

                  I hope that can help somebody.

                  (I'm sorry for my bad english)

                  1 Reply Last reply
                  2
                  • L Offline
                    L Offline
                    Lumbricus
                    wrote on last edited by
                    #11

                    Experienced the same Problem. Unable to right-click(go to slot) in form. The problem was unnecessary includes of my ui file (#include ui_mainwindow.h). Removing all includes of the ui file except the on used in MainWindow aka in MainWindow.h keep the include. After that i was able to use right-click ( go to slot) again. Did not clean Project, just rerun. cheers

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

                      it seems as if the ui_ include has to be the first one.

                      1 Reply Last reply
                      1
                      • K Offline
                        K Offline
                        kuschky
                        wrote on last edited by
                        #13

                        Hello, I had a similar problem. In my case it was related with the upper and lower case notation of include file names and the corresponding #include derictives. The problem was gone as soon the #include directive and the filenames were written in the same manner. On Windows filenames can be in lower or upper case.There should be no difference when accessing them - but it was. Here my Qt Creator was creating an include file with a filename like mybestclass.h but the include was noted as #include "MyBestClass.h". For some reason it could not create the slots with the "go to slot" functionality. Creating slots manualy was working fine and even jumping to the defintions and declarations with F2. Changing the include and filenam to the same notation solves my problem.

                        1 Reply Last reply
                        0
                        • K kottalovag

                          Hi guys, I just met this very same problem. I was refactoring my 3-year old project to c++11. I didn't like my MainWindow class to hold a bare Ui::MainWindow* ui rawpointer deleting it in the destructor. I tried to wrap it into std::unique_ptrUi::MainWindow and cleaned the destructor (for me it seems c++11 encourages us to clean out any ownership-handling responsibilities from destructors). Anyway, when I tried to go to a previously setup slot, I met this problem, too. I changed back the raw-ptr ui, (kept the unique_ptr buddy as well, haha) and it worked again.

                          S Offline
                          S Offline
                          sfkid
                          wrote on last edited by sfkid
                          #14

                          @kottalovag I had the same problem and was able to verify that the change from raw pointer to std::unique_ptr broke it. Thanks for the tip, you are a life saver.

                          In other words, if you have "std::unique_ptr<Ui::MainWindow> ui;" in your mainwindow.h, your project will still build and run, but you won't be able to use "go to slot" from the ui designer. To fix, change it back to "Ui::MainWindow* ui;".

                          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