Results 1 to 3 of 3

Thread: QMap corruption

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QMap corruption

    Hi,

    I have a problem with this piece of code:

    Qt Code:
    1. QMap<quint32,quint32> qMap;
    2. qMap[0] = 1;
    3. qMap[1] = 1;
    4. qMap[2] = 1;
    5. qMap[3] = 0;
    6. qMap[4] = 0;
    7. QFont qFontBold = ui.treeWidget->headerItem()->font(0);
    8. qFontBold.setBold(true);
    9. qText << "Hello";
    10. QTreeWidgetItem *pqItem = new QTreeWidgetItem(ui.treeWidget,qText);
    11. pqItem->setFont(1,qFontBold); //This line changes qMap[0] to 0
    12.  
    13. //Here, if I check the value of qMap[0] it contains 0 instead of 1
    14. quint32 qValue = qMap.value(0);
    To copy to clipboard, switch view to plain text mode 

    Using the debugger I can see that when setting the font to the item in the treeWidget, the qMap changes the value on key 0.

    Could anyone try this code if you get the same error. Or maybe I'm doing something wrong?

    Using Qt 4.8.1, Visual Studio 2008 and Windows XP.

    Thanks,
    Last edited by ^NyAw^; 6th March 2013 at 14:53.
    Òscar Llarch i Galán

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMap corruption

    Where and how qMap is defined ?

  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QMap corruption

    Hi,

    Sorry, I have changed the variable name when posting this. Read the code now


    Added after 48 minutes:


    Hi,

    Finally found what happens.
    I have connected the signal "itemChanged(QTreeWidgetItem*,int)" of QTreeWidget to a slot where it cheks if the item is cheked or not. As when setting the font the item changes, I modify the data of the QMap incorrectly as the item is not checked but I still not set the checkBox to true.
    I will disable the signals from the QTreeWidget until it is filled.

    Thanks,
    Last edited by ^NyAw^; 6th March 2013 at 15:40.
    Òscar Llarch i Galán

Similar Threads

  1. [Qt4.8] QML: Text corruption
    By flamaros in forum Qt Programming
    Replies: 11
    Last Post: 28th February 2013, 15:26
  2. Heap corruption detected
    By yaseminyilmaz in forum Qt Programming
    Replies: 1
    Last Post: 17th July 2012, 12:53
  3. Best way to fix a memory corruption issue?
    By agarny in forum Qt Programming
    Replies: 4
    Last Post: 3rd April 2012, 07:20
  4. memory corruption
    By Rambobino in forum Qt Programming
    Replies: 2
    Last Post: 10th August 2010, 21:35
  5. Widget corruption
    By grzywacz in forum Qt Tools
    Replies: 5
    Last Post: 28th May 2006, 11:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.