Results 1 to 4 of 4

Thread: Program crashes after changing cell in QTableWidget

  1. #1
    Join Date
    Sep 2011
    Posts
    86
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Program crashes after changing cell in QTableWidget

    Hello, I have a following problem.
    There is a QTableWidget with all cells filled with QTableWidgetItem objects.
    When I get signal cellChanged(int row, int column) inside connected slot I'm trying to get data from remote server and then populate cell with text. It takes a while to get data (about 500ms). In the same time when I click on a different cell and start to populate it with text program crashes. What is the reason? I was trying to embrace entire slot function with mutex.lock()/mutex.unlock but it seems not to work.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Program crashes after changing cell in QTableWidget

    Usually when a program crashes it is due to a bug in your code. Have you run your program in the debugger to see why and where it crashes?

  3. #3
    Join Date
    Sep 2011
    Posts
    86
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Program crashes after changing cell in QTableWidget

    Normally I would do this but I've just started to work with QtCreator and debugging seems not to work. When I start debugging in debug mode it looks like debugging is starting but it stops on constantly loading/unloading shell32.dll and nothing happens. Then I can only stop debugger.

    I think that it may be because of manipulating (reading) of table's cells in slot while in the same time I click on the cell that is being read and change content, but I'm not sure. I thought that it should work in different way, that only after slot function ends I would be able to click on second cell to edit it. It seems that these operations are independent.


    Added after 4 minutes:


    ...no, I've just created some testing code and it does work that way. There must be some other problem that I cannot find without debugger.
    Last edited by code_err; 1st November 2015 at 18:07.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Program crashes after changing cell in QTableWidget

    While the effect of event based programming can often look like concurrency, it is not, so using mutexes will not only not help, it can easily lead to a dead lock.

    Since you have not posted any code I can only assume you are using a pseudo-synchronous approach, e.g. a nested even loop or looping and calling process events.

    If you do that you need to ensure that you do not use any member variables to store request data or context, since every eother invocation will overwrite these again.
    It could be done with some form of associated container or even better fully asynchronous and using a request handler that encapsulates such an update.

    Of course all highly theoretical, since we have no indication what you are actually doing.

    Cheers,
    _

Similar Threads

  1. Replies: 3
    Last Post: 9th November 2012, 18:55
  2. QTableWidget cell color on maemo not changing
    By bmn in forum Qt Programming
    Replies: 1
    Last Post: 14th December 2010, 14:04
  3. Changing the background color of a cell in a QTableView
    By scarleton in forum Qt Programming
    Replies: 1
    Last Post: 30th June 2010, 13:23
  4. Replies: 1
    Last Post: 7th December 2009, 18:56
  5. QTableView and changing how a cell displays its contents
    By BitRogue in forum Qt Programming
    Replies: 2
    Last Post: 9th October 2009, 10:18

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.