You Are Here:

Community: Wiki

This page was last modified on 31 October 2009, at 15:42.

How to use QTableWidget

From Forum Nokia Wiki



ID ... Creation date 28 March 2009
Platform S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition Tested on devices S60 Emulator
Category Qt for S60 Subcategory Application


Keywords (APIs, classes, methods, functions): QTableWidget

Overview

The QTableWidget class provides an item-based table view with a default model.QTableWidget

Table widgets provide standard table display facilities for applications. The items in a QTableWidget are provided by QTableWidgetItem.

Preconditions

Various function

  • Sets the horizontal header labels using labels.
list<<"No."<<"Name"<<"Adder."<<"City"<<"Phone No.";
widget->setHorizontalHeaderLabels(list);
  • This property holds the number of rows in the table.
widget->setRowCount(5);
  • This property holds the number of columns in the table.
widget->setColumnCount(5);
  • This is used to set the widget in the table.
widget->setCellWidget(0,1,lbl);

Source code

Header File

#ifndef TABLEWIDGET_H
#define TABLEWIDGET_H
 
#include <QtGui/QWidget>
#include "ui_tableWidget.h"
#include<QStringList>
#include<QTableWidget>
#include<QHBoxLayout>
#include<QPushButton>
#include<QLabel>
class tableWidget : public QWidget
{
Q_OBJECT
 
public:
tableWidget(QWidget *parent = 0);
~tableWidget();
 
private:
QTableWidget *widget;
QHBoxLayout *layout;
QStringList list;
QPushButton *but1;
QLabel *lbl;
};
 
#endif // TABLEWIDGET_H

Source File

#include "tableWidget.h"
#include<QTableWidget>
#include<QStringList>
#include<QPushButton>
tableWidget::tableWidget(QWidget *parent)
: QWidget(parent)
{
layout=new QHBoxLayout(this);
list<<"No."<<"Name"<<"Adder";
widget=new QTableWidget(this);
but1=new QPushButton("Press",this);
widget->setRowCount(3);
widget->setColumnCount(15);
widget->setHorizontalHeaderLabels(list);
widget->setCellWidget(0,0,but1);
widget->setCellWidget(0,1,lbl);
layout->addWidget(widget);
setLayout(layout);
}
 
tableWidget::~tableWidget()
{
// No need to delete any object it has got a parent which is properly deleted.
 
}

Screenshot

More about QTableWidget

Image:Mytable001002.jpg

More about QTableWidget

Related Wiki Articles

      Rate This

       
      Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
      京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
      RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fTalkE3aE4cargeE5fscreenE5fsaverX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ