Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Weird behavior for Qt Creator when removing events for objects.



  • Over the course of debugging parts of my project I will occasionally remove functions for an object-say QListview and I no longer need the itemChanged event. So I will delete it from the MainWindow.cpp.

    Everything seems "fine" for the moment, however maybe 10 minutes go by and I update part of my code and sure enough I get a reference to a piece of code that I deleted. I don't have the error off the top of my head I am currently at work,, but for some reason the deletion of events for objects never stay deleted for long. It is quite annoying and I am curious if there is a fix for this.

    Also if anyone can have the "Tree" view not rely on dark theme colors while in project mode?

    Thanks.


  • Lifetime Qt Champion

    @voncloft said in Weird behavior for Qt Creator when removing events for objects.:

    remove functions for an object-say QListview and I no longer need the itemChanged event

    I don't quite understand what you mean.
    Can you please show some code - before and after the change you mean?

    Also, sometimes it helps to do a complete rebuild: delete build folder, run qmake and build.



  • @jsulm said in Weird behavior for Qt Creator when removing events for objects.:

    @voncloft said in Weird behavior for Qt Creator when removing events for objects.:

    remove functions for an object-say QListview and I no longer need the itemChanged event

    I don't quite understand what you mean.
    Can you please show some code - before and after the change you mean?

    Also, sometimes it helps to do a complete rebuild: delete build folder, run qmake and build.

    Say for example I have QListview and I am using the itemChanged to debug something.....then I find out I don't need itemChanged but instead need itemSelected so I delete itemChanged, its pointless no longer needed.

    So I keep pushing along and critiquing my app just doing whatever, then I hit the green arrow to run.....and then I get a reference to itemChanged for Qlistview saying referenced to non existing function.

    I will get an error to add to the moc file Yes to All, something about the project being changed outside the directory and I get an Elf error in the program. If I go to form_ui.h and remove the functioin of itemChanged it works....but I have to keep deleting the declarative statment, its as if Qt won't let me delete the declaration.

    I don't have the information off the top of my head, but its the best I can describe at the moment....I am currently at work so I am unable to debug at the moment, once I am home I will gladly enter the information.


  • Lifetime Qt Champion

    @voncloft

    Hi
    you must also delete them from mainwindow.h

    Slots are just like normal functions with a definition and a body so
    it must be removed from both .cpp and .h



  • @mrjj said in Weird behavior for Qt Creator when removing events for objects.:

    @voncloft

    Hi
    you must also delete them from mainwindow.h

    Slots are just like normal functions with a definition and a body so
    it must be removed from both .cpp and .h

    I have done that as well and still the event is readded for some reason.


  • Lifetime Qt Champion

    @voncloft

    Hi
    That can be some of the xx_ui files somehow ended up in project folder.
    Or the usual case where one must to a clean all, rebuild or even delete the build folder.

    In any case, if you delete the slot function, its normally gone.



  • @mrjj said in Weird behavior for Qt Creator when removing events for objects.:

    @voncloft

    Hi
    That can be some of the xx_ui files somehow ended up in project folder.
    Or the usual case where one must to a clean all, rebuild or even delete the build folder.

    In any case, if you delete the slot function, its normally gone.

    How do any of those things even happen?


  • Lifetime Qt Champion

    @voncloft
    Hi
    Hard to say. often with shadow building setting turning it on/of or change path.
    The reason for deleting the build folder is that sometimes make cachces things.


Log in to reply