Grid Widget



 Grid Widget provides the function that reads the external data by using scripts and represents it as a form of a table.



 Grid widget is an object that represents the data as a form of a table, and it separates into the data area representing the header and data. It is constructed to cells.

 If it is not able to represent the entire data on the screen, a  scroll bar or horizontal scroll bar occurs.

 The below shows the form of the grid widget.



 The detailed description of terms is as below.


Property

Description

Header

The area represents the preface on the grid widget.

Data

It is the value or String displayed on the grid widget.

Cell

The area represents each data. It is able to set and modify.

Vertical/Horizontal Scroll Bar

Occur when it is not able to represent the whole data on the screen, and the user can check other data to move the scroll bar.


 And the table consists of rows and columns. Rows increment by 1 from top to bottom the value 0 as the base. columns increment by 1 from left to right the value 0 as the base. It is able to check or set the data of cells by selecting rows and columns.

 The below shows the form of rows and columns.



Also, the area of the header and data is managed by separating each row and column. The below shows the form of rows and columns of the header and data area.






Methods



 To use the grid widget object, obtain the grid widget on the canvas by using the canvas object. Using grid widget objects, it is able to set a value on rows and columns or write the shape of tables.


Return Type

Method

Description

variant

cellData( row, column )

Read the data saved on the cell.


checkBoxChecked( int, int, bool )

It is a check event handler generating events depending on the check state of the check box.


clearAll()

Remove all data of the grid widget including the header.


clearData()

Remove all data of the grid widget.


clearHeader()

Remove all data of the header of the grid widget.


clearSelection()

Cancel the selection on cells.

int

columnCount()

Obtain the number of columns.


connect( eventName, func )

Register an event handler to the grid widget.

int

currentColumn()

Obtain the currently selected row on the grid widget.

int

currentRow()

Obtain the currently selected column on the grid widget.

str

dataText( row, column )

Obtain the String of the cell by selecting the entered row and column on the grid widget.

int

defaultTextAlignment()

Obtain the default String alignment.


fitByData()

Fit the size of all rows and columns on the size of data in the grid widget.


fitByHeader()

Fit the size of all rows and columns on the size of data in the grid widget header.

str

gridColor()

Obtain the line color of the grid widget.

str

headerText( row, column )

Obtain the String of cells by selecting the entered row and column on the grid widget header.


isChecked( row, column )

Read the check state of check boxes by selecting the row and column of the grid widget.


restoreHeader()

Set the header of the grid widget to the previous value.

int

rowCount()

Obtain the number of columns of the grid widget.

top, left, bottom, right

selectedRanged()

Read the range of the currently selected cells.


setAllHeaderBold( enable )

Set the width of all Strings of the grid widget header.


setAllHeaderTextSize( size )

Set the size of all Strings of the grid widget header.


setCellData( row, column, data )

Save the data to cells.


setCheckBox( row, column )

Add a check box by selecting the row and column of the grid widget.


setChecked( row, column, checked )

Set the check of check boxes by selecting the row and column of the grid widget.


setColumnWidth( column, width )

Set the width of columns.


setCurrentIndex( row )

Set the selected column of the grid widget.


setDataBackgroundColor( row, column, color )

Set the background color of cells by selecting the row and column of the grid widget.


setDataCellHeight( size )

Set the height of cells of the grid widget.


setDataCount( row, column )

Set the number of rows and columns of the grid widget.


setDataSpan( row, column, rowCount, columnCount )

Merge cells by saving rows and columns of the grid widget.


setDataText( row, column, text )

Set the String of cells by selecting the row and column of the grid widget.


setDataTextAlignment( row, column, flag )

Set the String alignment of cells by selecting the row and column of the grid widget.


setDataTextBold( row, column, enable )

Set the String width of cells by selecting the row and column of the grid widget.


setDataTextColor( row, column, color )

Set the String color of cells by selecting the row and column of the grid widget.


setDataTextSize( row, column, size )

Set the String size of cells by selecting the row and column of the grid widget.


setDefaultTextAlignment( flag )

Set the default String alignment of the grid widget.


setEditable( editable )

Set whether the entire data cell is editable.


setEditable( row, column, editable )

Set whether the cell is editable by selecting the row and columns of the grid widget.


setEnabled( enable )

Set enable or disable the grid widget.


setFrozenColumn( col )

Set the fixed column by selecting the row of the grid widget.


setGridColor( color )

Set the line color of the grid widget.


setHeaderBackgroundColor( color )

Set the background color of headers of the grid widget.


setHeaderBackgroundColor( row, column, color )

Set the background color of cells by selecting the row and column of the grid widget header.


setHeaderBold( enable )

Set the text width of headers of the grid widget.


setHeaderCellHeight( size )

Set the cell height of headers of the grid widget.


setHeaderCount( row, column )

Set the number of rows and columns of the grid widget header.


setHeaderSpan( row, column, rowCount, columnCount )

Merge cells by selecting rows and columns of the grid widget header.


setHeaderText( row, column, text )

Set the String of cells by selecting the row and column of the grid widget header.


setHeaderTextAlignment( row, column, flag )

Set the String alignment of cells by selecting the row and column of the grid widget header.


setHeaderTextBold( row, column, enable )

Set the String width of cells by selecting the row and column of the grid widget header.


setHeaderTextColor( color )

Change the text color of headers of the grid widget.


setHeaderTextColor( row, column, color )

Set the String color of cells by selecting the row and column of the grid widget header.


setHeaderTextSize( row, column, size )

Set the String size of cells by selecting the row and column of the grid widget header.


setHeaderTextSize( size )

Change the text size of headers of the grid widget.


setPushButton( row, column )

Insert a press button to the cell.


setSelectionMode( mode )

Set the data selection of the grid widget.



  setHeaderCount( row:The number of rows, column:The number of columns )


  setHeaderCount sets the number of rows and columns of the grid widget on its header.


  ㆍ row: Enter the number of rows of the header of the grid widget.

   column: Enter the number of columns of the header of the grid widget.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 4)  # Set data of the grid widget header to (2,4).




 



  setHeaderText( row:Rows, column:Columns, text:String )


  setHeaderText sets the String to the grid widget header. Set the String to the row and column the user entered.


  ㆍ row: Enter the row to set the String.

  ㆍ column: Enter the column to set the String.

  ㆍ text: Enter the String to set.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(1, 4)  # Set data of the grid widget header to (1,4).

       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) to 'Date'.

       grid.setHeaderText(0, 1, 'Moment')  # Set the text of (0,1) to 'Moment'.

       grid.setHeaderText(0, 2, 'Maximum')  # Set the text of (0,2) to 'Maximum'.

       grid.setHeaderText(0, 3, 'Cumulative')  # Set the text of (0,3) to 'Cumulative'.




 



  setHeaderTextColor( row:Rows, column:Columns, color:QColor objects )


  setHeaderTextColor sets the String color to the grid widget header. Set the String color to the row and column the user entered.


  ㆍ row: Enter the row to set the color of the String.

  ㆍ column: Enter the column to set the color of the String.

  ㆍ color: Enter the color using QColor.

 


  QColor object has to be set RGB color values and transparency values. Each value is an Integer number between 0 to 255.

  QColor object is used as follows.


  ㆍ Function

          QColor(red,green,blue,transparency)


  ㆍ Use example

          - Red: QColor(255,0,0,255)

          - Green: QColor(0,255,0,128)

          - Blue: QColor(0,0,255,255)



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(1, 4)  # Set data of the grid widget header to (1,4).

       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) to 'Date'.

       grid.setHeaderText(0, 1, 'Moment')  # Set the text of (0,1) to 'Moment'.

       grid.setHeaderText(0, 2, 'Maximum')  # Set the text of (0,2) to 'Maximum'.

       grid.setHeaderText(0, 3, 'Cumulative')  # Set the text of (0,3) to 'Cumulative'.


       # Set the text of (0,0) as black.

       grid.setHeaderTextColor(0, 0, QColor("#000000"))


       # Set the text of (0,1) as red.

       grid.setHeaderTextColor(0, 1, QColor("#FF0000"))


       # Set the text of (0,2) as green.

       grid.setHeaderTextColor(0, 2, QColor("#00FF00"))


       # Set the text of (0,3) as blue.

       grid.setHeaderTextColor(0, 3, QColor("#0000FF"))




 



  setHeaderSpan( row:Strat row, column:Start column, rowCount:The number of rows to merge, columnCount:The number of columns to merge )


  setHeaderSpan merges rows and columns of the grid widget header.


  ㆍ row: Enter the start row of the grid widget header.

  ㆍ column: Enter the start column of the grid widget header.

  ㆍ rowCount: Enter the number of rows to merge.

  ㆍ columnCount: Enter the number of columns to merge.



Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 4)  # Set data of grid widget header to (2,4).


       # Merge (0,0) and (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (0,2), (0,3) of the grid widget header.

       grid.setHeaderSpan(0, 1, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) to 'Date'.

       grid.setHeaderText(0, 1, 'Electricity')  # Set the text of (0,1) to 'Electricity'.

       grid.setHeaderText(0, 1, 'Moment')  # Set the text of (0,1) to 'Moment'.

       grid.setHeaderText(0, 2, 'Maximum')  # Set the text of (0,2) to 'Maximum'.

       grid.setHeaderText(0, 3, 'Cumulative')  # Set the text of (0,3) to 'Cumulative'.




 



  setHeaderTextAlignment( row:Rows, column:Columns, flag:Alignment )


  setHeaderTextAlignment sets the String alignment to rows and columns of the grid widget header.


  ㆍ row: Enter the row to set the color of String.

  ㆍ column: Enter the column to set the color of String.

  ㆍ flag: Enter the String alignment of the grid widget.

          - GridWidgetItem.Left: Align the text to the left.

          - GridWidgetItem.Right: Align the text to the right.

          - GridWidgetItem.Center: Align the text to the center.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 4)  # Set data of grid widget header to (2,4).


       # Merge (0,0) and (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (0,2), (0,3) of the grid widget header.

       grid.setHeaderSpan(0, 1, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) to 'Date'.

       grid.setHeaderText(0, 1, 'Electricity')  # Set the text of (0,1) to 'Electricity'.

       grid.setHeaderText(0, 1, 'Moment')  # Set the text of (0,1) to 'Moment'.

       grid.setHeaderText(0, 2, 'Maximum')  # Set the text of (0,2) to 'Maximum'.

       grid.setHeaderText(0, 3, 'Cumulative')  # Set the text of (0,3) to 'Cumulative'.


       for r in range(0, 2):

              for c in range(0, 4):


       # Align the text to the left.

       grid.setHeaderTextAlignment(r, c, GridWidgetItem.Left)




 



  setHeaderTextSize( row:Rows, column:Columns, size:Text size )


  setHeaderTextAlignment sets the text size to the grid widget header.


  ㆍ row: Enter the row to set the color of String.

  ㆍ column: Enter the column to set the color of String.

  ㆍ size: Enter the size of String.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 4)  # Set data of grid widget header to (2,4).


       # Merge (0,0) and (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (0,2), (0,3) of the grid widget header.

       grid.setHeaderSpan(0, 1, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) to 'Date'.

       grid.setHeaderText(0, 1, 'Electricity')  # Set the text of (0,1) to 'Electricity'.

       grid.setHeaderText(0, 1, 'Moment')  # Set the text of (0,1) to 'Moment'.

       grid.setHeaderText(0, 2, 'Maximum')  # Set the text of (0,2) to 'Maximum'.

       grid.setHeaderText(0, 3, 'Cumulative')  # Set the text of (0,3) to 'Cumulative'.


       for r in range(0, 2):

              for c in range(0, 4):


       # Set the size of text as 12.

       grid.setHeaderTextSize(r, c, 12)




 



  setHeaderTextBold( row:Rows, column:Columns, enable:0 or 1 )


  setHeaderTextBold sets the String width to rows and columns of the grid widget header.


   row: Enter the row of the grid widget.

   column: Enter the column of the grid widget.

   enable: If entering 1, it sets the String width as thick.

   enable: If entering 0, it sets the String width as normal.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 4)  # Set data of grid widget header to (2,4).


       # Merge (0,0) and (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (0,2), (0,3) of the grid widget header.

       grid.setHeaderSpan(0, 1, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) to 'Date'.

       grid.setHeaderText(0, 1, 'Electricity')  # Set the text of (0,1) to 'Electricity'.

       grid.setHeaderText(0, 1, 'Moment')  # Set the text of (0,1) to 'Moment'.

       grid.setHeaderText(0, 2, 'Maximum')  # Set the text of (0,2) to 'Maximum'.

       grid.setHeaderText(0, 3, 'Cumulative')  # Set the text of (0,3) to 'Cumulative'.


       # Set the width of text as normal.

       for r in range(0, 2):

              for c in range(0, 4):

                     grid.setHeaderTextBold(r, c, 0)


       # Set the width of text thicker.

       for r in range(0, 2):

              for c in range(0, 4):

                     grid.setHeaderTextBold(r, c, 1)




 



  setHeaderBackgroundColor( row:Rows, column:Columns, color:QColor objects )


  setHeaderTextColor sets the background color to the grid widget header.


  ㆍ row: Enter the row to set the color of String.

  ㆍ column: Enter the column to set the color of String.

  ㆍ color: Enter the background color using QColor.



  QColor object has to be set RGB color values and transparency values. Each value is an Integer number between 0 to 255.

  QColor object is used as follows.


  ㆍ Function

          QColor(red,green,blue,transparency)


  ㆍ Use example

          - Red: QColor(255,0,0,255)

          - Green: QColor(0,255,0,128)

          - Blue: QColor(0,0,255,255)


  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 4)  # Set data of grid widget header to (2,4).


       # Merge (0,0) and (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (0,2), (0,3) of the grid widget header.

       grid.setHeaderSpan(0, 1, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) to 'Date'.

       grid.setHeaderText(0, 1, 'Electricity')  # Set the text of (0,1) to 'Electricity'.

       grid.setHeaderText(0, 1, 'Moment')  # Set the text of (0,1) to 'Moment'.

       grid.setHeaderText(0, 2, 'Maximum')  # Set the text of (0,2) to 'Maximum'.

       grid.setHeaderText(0, 3, 'Cumulative')  # Set the text of (0,3) to 'Cumulative'.


       # Set the background color of the grid widget header as #BDD7EE(HEX).

       for r in range(0, 2):

              for c in range(0, 4):

                     grid.setHeaderBackgroundColor(r, c, QColor('#bdd7ee'))




 



  setAllHeaderBold( enable: 0 or 1  )


  setAllHeaderBold sets the String width of all grid widget header.


  ㆍ enable: If entering 1, it sets the String width as thick.

  ㆍ enable: If entering 0, it sets the String width as normal.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 4)  # Set data of grid widget header to (2,4).


       # Merge (0,0) and (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (0,2), (0,3) of the grid widget header.

       grid.setHeaderSpan(0, 1, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) to 'Date'.

       grid.setHeaderText(0, 1, 'Electricity')  # Set the text of (0,1) to 'Electricity'.

       grid.setHeaderText(0, 1, 'Moment')  # Set the text of (0,1) to 'Moment'.

       grid.setHeaderText(0, 2, 'Maximum')  # Set the text of (0,2) to 'Maximum'.

       grid.setHeaderText(0, 3, 'Cumulative')  # Set the text of (0,3) to 'Cumulative'.


       # Set the text as thick.

       grid.setAllHeaderBold(1);


       # Release the thick.

       grid.setAllHeaderBold(0);




  This is the screen of the text width setting of the entire header.

 


  This is the screen of the text width release of the entire header.

 



  setAllHeaderTextSize( size:Text size )


  setAllHeaderTextSize sets the String size of the grid widget header.


  ㆍ size: Enter the text size of the grid widget header.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 4)  # Set data of grid widget header to (2,4).


       # Merge (0,0) and (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (0,2), (0,3) of the grid widget header.

       grid.setHeaderSpan(0, 1, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) to 'Date'.

       grid.setHeaderText(0, 1, 'Electricity')  # Set the text of (0,1) to 'Electricity'.

       grid.setHeaderText(0, 1, 'Moment')  # Set the text of (0,1) to 'Moment'.

       grid.setHeaderText(0, 2, 'Maximum')  # Set the text of (0,2) to 'Maximum'.

       grid.setHeaderText(0, 3, 'Cumulative')  # Set the text of (0,3) to 'Cumulative'.

       

       # Set the size of text as 12.

       grid.setAllHeaderTextSize(12)




 



  setDataCount( row:The number of rows, column:The number of columns )


  setDataCount sets the number of rows and columns of the grid widget.


   row: Enter the number of rows of the grid widget data.

   column: Enter the number of columns of the grid widget data.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 4)  # Set data of grid widget header to (2,4).


       # Merge (0,0) and (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (0,2), (0,3) of the grid widget header.

       grid.setHeaderSpan(0, 1, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) to 'Date'.

       grid.setHeaderText(0, 1, 'Electricity')  # Set the text of (0,1) to 'Electricity'.

       grid.setHeaderText(0, 1, 'Moment')  # Set the text of (0,1) to 'Moment'.

       grid.setHeaderText(0, 2, 'Maximum')  # Set the text of (0,2) to 'Maximum'.

       grid.setHeaderText(0, 3, 'Cumulative')  # Set the text of (0,3) to 'Cumulative'.


       # Set data of the grid widget to (10,4).

       grid.setDataCount(10, 4)




 



  setDataSpan( row:Start row, column:Start column, rowCount:The number of rows to merge, columnCount:The number of columns to merge )


  setDataSpan merges rows and columns of the grid widget.


  ㆍ row: Enter the start row of the grid widget.

   column: Enter the start column of the grid widget.

   rowCount: Enter the number of rows to merge.

   columnCount: Enter the number of columns to merge.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Time')  # Set the text of (0,1) as 'Time'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);




 



  setDataText( row:Rows, column:Columns, text:String )


  setDataSpan sets the String to rows on columns of the grid widget.


   row: Enter the row to set the String.

   column: Enter the column to set the String.

   text: Enter the String to set.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Time')  # Set the text of (0,1) as 'Time'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '2 am'.




 



  setDataTextColor( row:Rows, column:Columns, color:Colors )


  setDataTextColor sets the String color to the row and column of the grid widget.


  ㆍ row: Enter the row to set the String.

  ㆍ column: Enter the column to set the String.

  ㆍ color: Enter the String color using the QColor object.



  QColor has to be set RGB color values and transparency values. Each value is an Integer number between 0 to 255.

  QColor object is used as follows.


  ㆍ Function

          QColor(red,green,blue,transparency)


  ㆍ Use example

          - Red: QColor(255,0,0,255)

          - Green: QColor(0,255,0,128)

          - Blue: QColor(0,0,255,255)



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.


       # Set the text color of (0,0) as QColor('#FF0000').

       grid.setDataTextColor(0, 0, QColor('#FF0000'))




 



  setDataBackgroundColor( row:Rows, column:Columns, color:Colors )


  setDataBackgroundColor sets the background color of rows and columns of the grid widget.


  ㆍ row: Enter the row to set.

   column: Enter the column to set.

   color: Enter the background color to set using QColor objects.


  QColor has to be set RGB color values and transparency values. Each value is an Integer number between 0 to 255.

  QColor object is used as follows.


  ㆍ Function

          QColor(red,green,blue,transparency)


  ㆍ Use example

          - Red: QColor(255,0,0,255)

          - Green: QColor(0,255,0,128)

          - Blue: QColor(0,0,255,255)



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.


       # Set the background color of the grid widget as DEE8F7(HEX value).

       for r in range(0,5):

               for c in range(0,2):

                     grid.setDataBackgroundColor(r,c,QColor("#DEE8F7"))




 



  setDataTextAlignment( row:Rows, column:Columns, flag:String alignment )


  setDataTextAlignment sets the String alignment to the row and column of the grid widget.


  ㆍ row: Enter the row of the grid widget.

  ㆍ column: Enter the column of the grid widget.

  ㆍ flag: Enter the String alignment of the grid widget.

          - GridWidgetItem.Left: Align the text to the left.

          - GridWidgetItem.Right: Align the text to the right.

          - GridWidgetItem.Center: Align the text to the center.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.

       

       # Align the text to the left.

       for r in range(0,5):

              for c in range(0,2):

                     grid.setDataTextAlignment(r,c,GridWidgetItem.Left);




 



  setDataTextSize( row:Rows, column:Columns, size:String size )


  setDataTextSize sets the String size to rows and columns of the grid widget.


  ㆍ row: Enter rows of the grid widget.

  ㆍ column: Enter columns of the grid widget.

   size: Enter the String size of the grid widget.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.


       # Set the size of text as 12.

       for r in range(0,5):

              for c in range(0,2):

                     grid.setDataTextSize(r,c,12);




 



  setDataTextBold( row:Rows, column:Columns, enable: 0 or 1 )


  setDataTextBold sets the String width to rows and columns of the grid widget.


   row: Enter rows of the grid widget.                                                                                                                                                                                                                              

   column: Enter columns of the grid widget.

   enable: Enter 0 or 1.

          - If entering 1, the String is getting thicker.

          - If entering 0, the String is not getting thicker.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.


       # Set the text of the grid widget as thick.

       for r in range(0,5):

              for c in range(0,2):

                       grid.setDataTextBold(r,c,1);


       # Release the thick.

       for r in range(0,5):

              for c in range(0,2):

                     grid.setDataTextBold(r,c,0);




  This is the set of String width.

 


  This is the release of String width.

 



  setEditable( row:Rows, column:Columns, enable: 0 or 1 )


  setEditable sets whether rows and columns of the grid widget is editable.


  ㆍ row: Enter rows of the grid widget.

  ㆍ column: Enter columns of the grid widget.

  ㆍ enable: Enter 0 or 1.

          - If entering 1, set cells of the grid widget editable.

          - If entering 0, set cells of the gird widget uneditable.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.

       

       # Set cells between (0,0) to (5,2) ineditable.

       for r in range(0,5):

              for c in range(0,2):

                     grid.setEditable(r,c,0)




 



  fitByData()


  fitByData fits the size of all rows and columns on the size of data.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.

       grid.setDataText(0, 2, '30000')  # Set the text of (0,2) as '30000'.

       grid.setDataText(0, 3, '60000')  # Set the text of (0,3) as '60000'.

       grid.setDataText(0, 4, '90000')  # Set the text of (0,4) as '90000'.


       # Fit the size of all rows and columns on the size of data. data.

       grid.fitByData()




 



  fitByHeader()


  ffitByHeader fits the size of all rows and columns on the size of the header data.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.

       grid.setDataText(0, 2, '30000')  # Set the text of (0,2) as '30000'.

       grid.setDataText(0, 3, '60000')  # Set the text of (0,3) as '60000'.

       grid.setDataText(0, 4, '90000')  # Set the text of (0,4) as '90000'.


       # Fit the size of all rows and columns on the size of the header data.

       grid.fitByHeader()




 



  setSelectionMode( mode:Selection )


  setSelectionMode sets the data selection of the grid widget.


  ㆍ mode: Enter the cell selection of the grid widget.

          - GridWidgetItem.NoSelection: Set no selection to the cell.

          - GridWidgetItem.Single: Set a single selection to the cell.

          - GridWidgetItem.Multi: Set a multi selection to the cell



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.

       grid.setDataText(0, 2, '30000')  # Set the text of (0,2) as '30000'.

       grid.setDataText(0, 3, '60000')  # Set the text of (0,3) as '60000'.

       grid.setDataText(0, 4, '90000')  # Set the text of (0,4) as '90000'.


       #Set a single selection to the cell.

       grid.setSelectionMode(GridWidgetItem.Single)


       #Set a multi selection to the cell.

       grid.setSelectionMode(GridWidgetItem.Multi)




  This is the setting of a single selection.

 


  This is the setting of a multi selection.

 



  int currentRow()


  currentRow obtains the currently selected row on the grid widget.


  Return the number of the currently selected row on the grid widget.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       value = grid.currentRow()  # Return the number of the currently selected row on the grid widget.

       print "Current Row : ", value


 


 



  int currentColumn()


  currentColumn obtains the currently selected column on the grid widget.


  Return the number of the currently selected column on the grid widget.



  Example)



       grid = canvas.getObject(GridWidget')  # Obtain the grid widget.

       value = grid.currentColumn()  # Return the number of the currently selected column on the grid widget.

       print “Current Column : “, value




 



  int rowCount()


  rowCount obtains the number of rows of the grid widget.


  Return the number of rows as an Integer value.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.

       grid.setDataText(0, 2, '30000')  # Set the text of (0,2) as '30000'.

       grid.setDataText(0, 3, '60000')  # Set the text of (0,3) as '60000'.

       grid.setDataText(0, 4, '90000')  # Set the text of (0,4) as '90000'.


       # Obtain the number of rows of the grid widget.

       rows = grid.rowCount()

       print 'Row count : ', rows




  This is a result.

 

       >> Row count : 5

 



  int columnCount()


  columnCount obtains the number of columns of the grid widget.


  Return the number of columns as an Integer value.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.

       grid.setDataText(0, 2, '30000')  # Set the text of (0,2) as '30000'.

       grid.setDataText(0, 3, '60000')  # Set the text of (0,3) as '60000'.

       grid.setDataText(0, 4, '90000')  # Set the text of (0,4) as '90000'.


       # Obtain the number of columns of the grid widget.

       column = grid.columnCount()

       print 'Column count : ', column

 



  This is a result.

 

       >> Column count : 5

 



  str dataText( row:Rows, column:Columns )


  dataText obtains the String of rows and columns of the grid widget.


  Return the String of rows and columns of the grid widget.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.

       grid.setDataText(0, 2, '30000')  # Set the text of (0,2) as '30000'.

       grid.setDataText(0, 3, '60000')  # Set the text of (0,3) as '60000'.

       grid.setDataText(0, 4, '90000')  # Set the text of (0,4) as '90000'.


       # Obtain the text of the 0th row and the 0th column.

       value = grid.dataText(0,0)

       print "Cell(0, 0) : ", value


 


  This is a result.

 

       >> Cell(0, 0) :1st

 



  str headerText( row:Rows, column:Columns )


  headerText obtains the String of rows and columns of the grid widget header.


  Return the String of rows and columns of the grid widget header.



  Example)

       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.

       grid.setDataText(0, 2, '30000')  # Set the text of (0,2) as '30000'.

       grid.setDataText(0, 3, '60000')  # Set the text of (0,3) as '60000'.

       grid.setDataText(0, 4, '90000')  # Set the text of (0,4) as '90000'.


       # Obtain the text of the 0th row and the 0th column.

       value = grid.headerText(0,0)

       print "Header(0,0) : ", value


 


  This is a result.

 

       >> Cell(0, 0) :1st

 



  clearAll()


  clearAll removes all data of the grid widget including the header.


 

  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.clearAll()  # Remove all data of the grid widget including the header.





  clearData()


  clearData removes all data of the grid widget.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.

       grid.setDataText(0, 2, '30000')  # Set the text of (0,2) as '30000'.

       grid.setDataText(0, 3, '60000')  # Set the text of (0,3) as '60000'.

       grid.setDataText(0, 4, '90000')  # Set the text of (0,4) as '90000'.


       # Remove all data of the grid widget.

       grid.clearData()


 


 



  clearHeader()


  clearHeader removes all header of the grid widget.



  Example)


       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.

       grid.setDataText(0, 2, '30000')  # Set the text of (0,2) as '30000'.

       grid.setDataText(0, 3, '60000')  # Set the text of (0,3) as '60000'.

       grid.setDataText(0, 4, '90000')  # Set the text of (0,4) as '90000'.

       

       # Remove all header of the grid widget.

       grid.clearHeader()




 



  setDefaultTextAlignment( flag: Text alignment )


  setDefaultTextAlignment sets the default String alignment of the grid widget.


  ㆍ flag: Enter the default String alignment of the grid widget.

          - GridWidgetItem.Left: Left alignment

          - GridWidgetItem.Right: Right alignment

          - GridWidgetItem.Center: Center alignment



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.


       #Set the default alignment as a left alignment.

       grid.setDefaultTextAlignment(GridWigetItem.Left)


       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.

       grid.setDataText(0, 2, '30000')  # Set the text of (0,2) as '30000'.

       grid.setDataText(0, 3, '60000')  # Set the text of (0,3) as '60000'.

       grid.setDataText(0, 4, '90000')  # Set the text of (0,4) as '90000'.




 



  int defaultTextAlignment()


  defaultTextAlignment obtains the default String alignment set on the grid widget.


   Return an Integer number between 0 to 2. The meaning of each number is as below.

          - 0 : GridWidgetItem.Left Left alignment

          - 1 : GridWidgetItem.Right Right alignment

          - 2 : GridWidgetItem.Center Center alignment



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       value = grid.defaultTextAlignment()  # Obtain the default alignment.

       print 'value:',value


       # Left alignment

       if value == GridWidgetItem.Left:

               print 'GridWidgetItem.Left'


       # Right alignment

       elif value == GridWidgetItem.Right:

               print 'GridWidgetItem.Right'


       # Center alignment

       elif value == GridWidgetItem.Center:

               print 'GridWidgetItem.Center'


 



  setGridColor( color:Color )


  setGridColor sets the line color of the grid widget.


  ㆍ color: Set the line color of the grid widget. Set the line color using the QColor object.


  QColor object has to be set RGB color values and transparency values. Each value is an Integer number between 0 to 255.

  QColor is used as follows.


  ㆍ Function

          QColor(red,green,blue,transparency)


  ㆍ Use example

          - Red: QColor(255,0,0,255)

          - Green: QColor(0,255,0,128)

          - Blue: QColor(0,0,255,255)



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.

       grid.setDataText(0, 2, '30000')  # Set the text of (0,2) as '30000'.

       grid.setDataText(0, 3, '60000')  # Set the text of (0,3) as '60000'.

       grid.setDataText(0, 4, '90000')  # Set the text of (0,4) as '90000'.


       # Set the line color of the grid widget as blue.

       grid.setGridColor(QColor(0, 0, 255, 255));




 



  str gridColor()


  gridColor obtains the line color set on the grid widget.


   Return the String represented by HEX value.

  ㆍ Each RGB value is expressed in two decimal, hexadecimal. The expression range is 00 to FF.

  ㆍ Example) RGB values and HEX String

          - Black : QColor(0,0,0,255)     #000000

          - White : QColor(255,255,255)     #FFFFFF

          - Red : QColor(255,0,0)     #FF0000



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       value = grid.gridColor();  # Obtain the line color of the grid widget.

       print value

 




  setEnabled( enable:0 or 1 )


  setEnabled sets enable or disable the grid widget.


  ㆍ enable : Enter enable or disable the grid widget as a number.

          - 0 : Disable the grid widget.

          - 1 : Enable the grid widget.



  Example)

 


       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of the grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       # Merge (0,0), (1,0), (2,0) of the grid widget.

       grid.setDataSpan(0, 0, 3, 1);


       grid.setDataText(0, 0, '1st')  # Set the text of (0,0) as '1st'.

       grid.setDataText(1, 0, '2nd')  # Set the text of (1,0) as '2nd'.

       grid.setDataText(2, 0, '3rd')  # Set the text of (2,0) as '3rd'.

       grid.setDataText(0, 1, '0 am')  # Set the text of (0,1) as '0 am'.

       grid.setDataText(1, 1, '1 am')  # Set the text of (1,1) as '1 am'.

       grid.setDataText(2, 1, '3 am')  # Set the text of (2,1) as '3 am'.

       grid.setDataText(0, 2, '30000')  # Set the text of (0,2) as '30000'.

       grid.setDataText(0, 3, '60000')  # Set the text of (0,3) as '60000'.

       grid.setDataText(0, 4, '90000')  # Set the text of (0,4) as '90000'.


       # Disable the grid widget.

       grid.setEnabled(0);


       # Enable the grid widget.

       grid.setEnabled(1);




  This is the disabled grid widget.

 


  This is the enabled grid widget.

 



  restoreHeader()


  restoreHeader sets the header of the grid widget back to the previous value.  



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.restoreHeader()  # Set the header of the grid widget back to the previous value.






  setHeaderCellHeight( size:The height of cells )


  setHeaderCellHeight sets the height of cells of the grid widget header.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of th grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)


       # Set the height of cells of the grid widget as 30.

       grid.setHeaderCellHeight(30)




 



  setDataCellHeight( size:The height of cells )


  setHeaderCellHeight sets the height of cells of the grid widget.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of th grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       

       for row in range(0, 5):

              str = row

              grid.setDataText(row, 0, str)


       # Set the height of cells of the grid widget as 30.

       grid.setDataCellHeight(30)




 



  setEditable( editable:0 or 1 )


  setEditable sets whether all of the data is editable.


  ㆍ Set whether the cell of the grid widget is editable.

          - 1 : Set editable.

          - 0 : Set uneditable.



  Example)




       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of th grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)


       for row in range(0, 5):

              str = row

              grid.setDataText(row, 0, str)


       # Set the entire data editable.

       grid.setEditable(1)




 



  setHeaderTextColor( color:Colors )


  setHeaderTextColor changes the text color of headers of the grid widget.


  ㆍ Set the text color of headers of the grid widget. Set the color using QColor.


  QColor has to be set RGB color values and transparency values. Each value is an Integer number between 0 to 255.

  QColor is used as follows.


  ㆍ Function

          QColor(red,green,blue,transparency)


  ㆍ Use example

          - Red: QColor(255,0,0,255)

          - Green: QColor(0,255,0,128)

          - Blue: QColor(0,0,255,255)



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of th grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)


       # Change the text color of headers of the grid widget.

       grid.setHeaderTextColor(QColor(70,129,189))


 


 



  setHeaderTextSize( size:Text size )


  setHeaderTextSize changes the text size of headers of the grid widget.


  ㆍ size : Enter the size of texts.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of th grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)


       # Change the text size of headers of the grid widget to 12.

       grid.setHeaderTextSize(12)




 



  setHeaderBold( enable:0 or 1 )


  setHeaderBold sets the bold of the grid widget header.


   enable : Set whether the header text is bold.

          - 1 : Bold

          - 0 : Not bold



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of th grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)


       # Set the text of headers bold.

       grid.setHeaderBold(1)


 


 



  setHeaderBackgroundColor( color:Colors )


  setHeadeBackgroundColor sets the background color of the grid widget header.


   color: Set the background color of the header. Set the color using QColor.


  QColor object has to be set RGB color values and transparency values. Each value is an Integer number between 0 to 255.

  QColor is used as follows.


  ㆍ Function

          QColor(red,green,blue,transparency)


  ㆍ Use example

          - Red: QColor(255,0,0,255)

          - Green: QColor(0,255,0,128)

          - Blue: QColor(0,0,255,255)



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setHeaderCount(2, 5)  # Set data of th grid widget header to (2,5).


       # Merge (0,0), (1,0) of the grid widget header.

       grid.setHeaderSpan(0, 0, 2, 1);


       # Merge (0,1), (1,1) of the grid widget header.

       grid.setHeaderSpan(0, 1, 2, 1);


       # Merge (0,2), (0,3), (0,4) of the grid widget header.

       grid.setHeaderSpan(0, 2, 1, 3);


       grid.setHeaderText(0, 0, 'Date')  # Set the text of (0,0) as 'Date'.

       grid.setHeaderText(0, 1, 'Date')  # Set the text of (0,1) as 'Date'.

       grid.setHeaderText(0, 2, 'Electricity')  # Set the text of (0,2) as 'Electricity'.

       grid.setHeaderText(1, 2, 'Moment')  # Set the text of (1,2) as 'Moment'.

       grid.setHeaderText(1, 3, 'Maximum')  # Set the text of (1,3) as 'Maximum'.

       grid.setHeaderText(1, 4, 'Cumulative')  # Set the text of (1,4) as 'Cumulative'.


       # Set data of the grid widget to (5,5).

       grid.setDataCount(5, 5)

       # Set the text color of the grid widget header as QColor(255,255,255).

       grid.setHeaderTextColor(QColor(255, 255, 255))


       # Set the background color of the grid widget header as QColor(79,129,189).

       grid.setHeaderBackgroundColor(QColor(79, 129, 189))




 



  setColumnWidth( column, width )


  Set the width of cells.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setColumnWidth(0 , 200) # Set the width of 0th cell as 200.





  setCellData( row, column, data )


  Save the data to the cell.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setCellData(2, 2, 'key')  # Set the data of (2,2) as key.





  variant cellData( row, column )


  Read the data saved on the cell.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       data = grid.cellData(2, 2)  # Read the data of (2,2).





  top, left, bottom, right selectedRanged()


  Read the range of the currently selected cells.




  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       top, left, bottom, right = grid.selectedRange( )  # Read the range of the selected cell on the current grid widget.


       # The printed values are 0, 0, 3, 2.

       print top, left, bottom, right





  setPushButton( row, column )


  Insert the press button to the cell.



  Example)


 

       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       data = grid.setPushButton(4, 3)  # Insert the push button to (4,3).







  connect( eventName:Event handler name , func:Receiving function )


  Receive an event of the grid widget. Events occur in those happens.


    1. Clicking cells
    2. Double clicking cells
    3. Clicking the button in the cell



  Example)



       def handleCellSelected(row,column):

              print 'cell selected'


       def handleCellDobleClicked(row,column):

              print 'cell selected'


       def handleCellButtonClicked(row,column):

              print 'cell selected'


       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.


       # If selecting the cell, handleCellSelected function is recalled.

       grid.connect('currentChanged(int,int)', handleCellSelected)


       # If Double Clickin the cell. handleCellDoubleClicked function is recalled.

       grid.connect('cellDoubleClicked(int,int)', handleCellDobleClicked)


       # If clicking the button in the cell, handleCellButtonClicked is recalled.

       grid.connect('handleCellDobleClicked(int,int)', handleCellButtonClicked)







  clearSelection()


  Cancel the selection of cells.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.clearSelection()  # Cancel the selectiong of cells.




  Results)






  setFrozenColumn( col:Columns )


  setFrozenColumn sets the fixed column by selecting the row of the grid widget.


  ㆍ col: Enter columns to hold.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setFrozenColumn(0)  # Set the 0th column to the fixed column.




  Results)






  setCheckBox( row:Rows, col:Columns )


  setCheckBox inserts a check box by selecting the row and column of the grid widget.


  ㆍ row: Enter rows to insert the check box.

  ㆍ col: Enter columns to insert the check box.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setCheckBox(3, 3)  # Insert a check box to (3,3).




  Results)






  isChecked( row:Rows, col:Columns )


  isChecked reads the check state of check boxes by selecting the row and column of the grid widget.


  ㆍ row: Enter the row to check the state of check boxes.

  ㆍ col: Enter the column to check the state of check boxes.



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.isChecked(3, 3)  # Read the check box state of (3,3).







  setChecked( row:Rows, col:Columns, checked:Check state )


  setChecked sets the checks state of check boxes by selecting rows and columns of the grid widget.


  ㆍ row: Enter rows to set the check of check boxes.

  ㆍ col: Enter columns to set the check of check boxes.

  ㆍ checked: Set the check state of check boxes.

          - Unchecked : 0

          - Checked : 1



  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setChecked(3, 3, 1)  # Set the check box of (3,3) to the checked state.




  Results)

 



  checkBoxChecked( int:Rows, int:Columns, bool:Check state )


  Events occur based on the check state of check boxes by selecting rows and columns.



  Example)



       def cellButtonClicked2(row, column, checked)

              print row, column, checked


       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.


       # cellButtonClicked2 function is recalled based on the state of check boxes by selecting rows and columns.

       grid.connect('checkBoxChecked(int, int, bool)', cellButtonClicked2)





  setCurrentIndex( int:Rows )


  Display the column on the grid widget.


  Example)



       grid = canvas.getObject('GridWidget')  # Obtain the grid widget.

       grid.setCurrentIndex(4)  # Display the 4th row of the grid widget.




  Results)