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. Very newbie question - delete object
Forum Update on Monday, May 27th 2025

Very newbie question - delete object

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 121 Views
  • 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
    Fbs7
    wrote on last edited by
    #1

    Sorry for the very basic question... but I'm at my 3rd day at this and I can't find why this is breaking this up... In Visual Studio 2019 latest update (16.10.2) with Qt latest update (5.12.11) installed from Offline Installer for VC2017, this works fine:

    int main(int argc, char **argv)
    {
    	QApplication app(argc, argv);
    	QMainWindow* pmain = new QMainWindow();
    	delete pmain;
    }
    

    while this throws an exception on the delete:

    int main(int argc, char **argv)
    {
    	QApplication app(argc, argv);
    	QMainWindow* pmain = new QMainWindow();
    	pmain->setObjectName(QString("Yep"));
    	delete pmain;
    }
    

    any method that I call with numbers and other objects work fine, but it seems that any method call with QString makes the delete on the object to fail with an unnamed exception. Meanwhile QString by itself work fine, for example this has no problems:

    int main(int argc, char **argv)
    {
    	QApplication app(argc, argv);
    	QMainWindow* pmain = new QMainWindow();
    	QString * pstr = new QString("Yep");
    	delete pstr;
    	delete pmain;
    }
    

    Maybe there's some hidden setting somewhere on how QObjects handle QStrings? Any suggestion is appreciated.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Fbs7
      wrote on last edited by Fbs7
      #2

      Ah... it was one of those things... when you stop overthinking it the solution suddenly comes up.

      I was linking the release Qt5Widgets (Qt5Widgets.lib) with a debug CRT, and that was throwing the problem. Once I changed that to the debug one (Qt5Widgetsd.lib) the problem went away.

      I guess can't mix those up. Sorry the trouble, problem is resolved.

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved