Important: Please read the Qt Code of Conduct -

Qt Creator slot location

  • I created a new QT application using creator, and put a bunch of widgets on the mainwindow form. If I right-clicked, say, a button, and selected 'go to slot', creator would very helpfully add the declaration of the slot to mainwindow.h, and an empty slot function in mainwindow.cpp. Excellent, just what I want.
    Then, things turned strange...
    I added a number of source files to the project (.h and .cpp). After that, when I used 'got to slot', the automatically generated declaration and stub function ended up in one of these new files, instead of mainwindow. This continued for a while, during which time more sources were added, and then, quite unpredictably, creator switched it's target again when I added yet more source files.
    Funnier yet, when I added more forms, 'go to slot' on any of those correctly ended up in the corresponding source files (so far, they may start wandering around at any time..)

    I find that I have no control whatsoever over which source files the slots will end up in. Has anyone else run into this? Does anyone here know how to control where the slots to end up?



  • I just experienced a very similar issue where I click 'Go to slot' on a button in a form, but the slot appears in the mainwindow.cpp/h files.

Log in to reply