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. QString in a struct

QString in a struct

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 432 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.
  • P Offline
    P Offline
    Publicnamer
    wrote on last edited by
    #1

    I have some code that allocates an array of structs, and in each string is a QString (not a QString*).
    I find that when I delete that array, I get an error: malloc is trying to do a bad free.
    Is it not allowed to put a QString in a struct or array of structs?

    struct foo {
      QString s;
      int i;
    };
    int main() {
      struct foo *f = new struct foo [100];
       delete f; // error
    }
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      mpergand
      wrote on last edited by mpergand
      #2

      try delete[] f;

      warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete]
      delete f; // error

      1 Reply Last reply
      4

      • Login

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