Results 1 to 2 of 2

Thread: hi everyone.. Error filingl the data into the spreadsheet.

  1. #1
    Join Date
    Apr 2013
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default hi everyone.. Error filingl the data into the spreadsheet.

    i use the following to fill the data into the spreadsheet. the fill_dataNC function is called every time user clicks ok button after giving input.
    but it takes only the first 2 to 4 inputs and den gives this error --

    *** glibc detected *** ./shm1: malloc(): memory corruption (fast): 0x00000000011e3f11 ***

    please help me solve this

    void Spreadsheet::clear()
    {

    setRowCount(0);
    setColumnCount(0);
    setRowCount(RowCount);
    setColumnCount(ColumnCount);

    tableWidget = new QTableWidget(0, ColumnCount);
    for (int i = 0; i < RowCount; ++i)
    {
    int row = tableWidget->rowCount();
    tableWidget->insertRow(row);
    }

    setCurrentCell(0,0);
    }

    void Spreadsheet::fill_dataNC()
    {

    int rowNo = ip3; // user input
    int colNo = ip1; // user input
    int sampRa = ip2; // user input
    if(flag == 0)
    {
    while(rowNo < RowCount)
    {
    setItem(rowNo,colNo,new QTableWidgetItem(QString::number(a16bit, 16) + QChar('x')));
    item(rowNo,colNo)->setBackgroundColor(Qt::lightGray);
    wordCount++;
    emptyCount--;
    rowNo = rowNo + sampRa;
    }
    }
    else
    {
    while(rowNo < RowCount)
    {
    while(colNo < ColumnCount)
    {
    setItem(rowNo,colNo,new QTableWidgetItem(QString::number(a16bit, 16) + QChar('x')));
    item(rowNo,colNo)->setBackgroundColor(Qt::cyan);
    wordCount++;
    emptyCount--;
    colNo = colNo + sampRa;
    }
    rowNo++;
    }
    }

    }

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Wiki edits
    15

    Default Re: hi everyone.. Error filingl the data into the spreadsheet.

    Information is not sufficient, with the available information, this is what I can tell

    First use [CODE]...[\CODE] (change \ to /) tags for posting code.

    What is Spreadsheet, I assume QTableWidget derived class?
    At which line does the error occur, I assume it is setItem(). When you call setItem() you need make sure that the particular row exists in the table.

    Eg: If you want to insert into 10th row, you have to make sure (insert required rows) that 10th (index 9) row exists in the table else program may crash.

    BTW: You should have posted this in Qt Newbie forum
    Last edited by Santosh Reddy; 25th April 2013 at 20:33.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

Similar Threads

  1. Design of spreadsheet
    By incartasa in forum Newbie
    Replies: 1
    Last Post: 25th November 2009, 11:06
  2. QTreeView like excel spreadsheet
    By Stapl in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2009, 11:13
  3. creating Spreadsheet file
    By rajesh in forum Qt Programming
    Replies: 0
    Last Post: 26th May 2009, 10:54
  4. Spreadsheet of QCheckBoxes...help!
    By JonathanForQT4 in forum Newbie
    Replies: 7
    Last Post: 11th July 2007, 11:20
  5. scrolling like a spreadsheet
    By Honestmath in forum Qt Programming
    Replies: 2
    Last Post: 18th February 2006, 17:46

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
  •  
Qt is a trademark of The Qt Company.