[Qt-interest] How to reverse the order of the rows in a QTableWidget
Bijay Panda
bijaykumar.mail at gmail.com
Fri Sep 17 06:26:21 CEST 2010
Hi All,
I am working on QT 4.5.2 on linux.I want to reverse the order of rows in my
QTableWidget on a pushButton click outside the QTableWidget ( means 1-10
to 10-1).This is the ay I am doing..But its not working..Actually it's
unable to remove the cellWidget.
connect(m_pcBtnReverse,SIGNAL(clicked(bool)),this,SLOT(reverseRouteOnClick(bool)));
bool RoutesGUI::reverseRouteOnClick(bool bIndex_)
{
/*Reverses order of rows i.e set the item in descending if its in
ascending order*/
int usiRowCount = m_pcTblInput->rowCount();
int usiCol = 2;
/*Gets the contents of all the row from GUI table by passing the total
row number and coloumn number*/
char*** pppchRows = (char***)calloc (usiRowCount, sizeof(char**));
/*Get all the records from GUI table*/
for( int i = m_pcTblInput->rowCount()-1;i>= 0;i--)
{
pppchRows[i] = getRow(i);
}
/*Remove all the cell widget from GUI table*/
for( int i = m_pcTblInput->rowCount()-1; i >= 0;i--)
{
for( int j = 0;j< 2;j++)
{ cout<<"Removing cellwidget:"<<endl;
m_pcTblInput->removeCellWidget(i, j); }
}
/*Set items in reverse order into the table*/
for( int i = 0;i< m_pcTblInput->rowCount();i++)
{
QTableWidgetItem* pcTblItem;
for( int j = 0;j< 2;j++)
{
cout<<"GUI::reverseRouteOnClick : row : "<< i <<" and column :
"<< j <<" is : " << pppchRows[i][j]<<endl;
/*Set the item to Table for column 0 and 1 */
pcTblItem = new QTableWidgetItem (tr(pppchRows[i][j]));
m_pcTblInput->setItem(i, j, pcTblItem);
}
}
}
Any help is appreciated.Thanx in advace
--
Best Regards
Bijay Kumar Panda
Mob-9739591816
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100917/7eb135db/attachment.html
More information about the Qt-interest-old
mailing list