HMG4 GRID problem

Moderator: Rathinagiri

Post Reply
Ricci
Posts: 255
Joined: Thu Nov 19, 2009 2:23 pm

HMG4 GRID problem

Post by Ricci »

Does anyone know why the cursor keys are not working in a grid? Neither in my program nor in the demos.
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: HMG4 GRID problem

Post by mrduck »

Ricci wrote:Does anyone know why the cursor keys are not working in a grid? Neither in my program nor in the demos.
It's the same problem that was in virtualgrid.

In METHOD DoKeyBoardEvents( e ) CLASS GRID change all the RETURN .T. into RETURN .F. in all places where the event is not handled by the method and should be passed back to Qt, for example here:

Code: Select all

   IF !::lAllowEdit .or. ::lMultiSelect
   // Nothing doing
      RETURN .T.     <======== must be .F.
After a quick look at the code, the 5 RETURN in the method should return
.T. .F. .F. .T. .F.
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: HMG4 GRID problem

Post by mrduck »

Anyway, GRID class needs a bit of code refactoring....
Ricci
Posts: 255
Joined: Thu Nov 19, 2009 2:23 pm

Re: HMG4 GRID problem

Post by Ricci »

Thank you.

2 minor problems:

1. If a GRID or VirtualGrid contains only 1 record than the header ist always blue, even if it has the focus or not.

2. If you use :ColumnJustify { .... } in GRID the text in all cells is vertical top aligned. See Demo_3 in GRID samples.
Ricci
Posts: 255
Joined: Thu Nov 19, 2009 2:23 pm

Re: HMG4 GRID problem

Post by Ricci »

I found the solution for the display problem with :ColumnJustify

In grid.prg this part in METHOD Cell should be changed:

Code: Select all

      ELSEIF Pcount() == 3
         oItem := QTableWidgetItem()
         IF ValType( ::aColumnJustify ) != 'U'
            DO CASE
               CASE ::aColumnJustify[nCol] == GRID_JTFY_LEFT
                  oItem:setTextAlignment( Qt_AlignLeft )
               CASE ::aColumnJustify[nCol] == GRID_JTFY_RIGHT
                  oItem:setTextAlignment( Qt_AlignRight )
               CASE ::aColumnJustify[nCol] == GRID_JTFY_CENTER
                  oItem:setTextAlignment( Qt_AlignHCenter )
            ENDCASE
         ENDIF
to

Code: Select all

      ELSEIF Pcount() == 3
         oItem := QTableWidgetItem()
         IF ValType( ::aColumnJustify ) != 'U'
            DO CASE
               CASE ::aColumnJustify[nCol] == GRID_JTFY_LEFT
                  oItem:setTextAlignment( hb_bitOR( Qt_AlignVCenter, Qt_AlignLeft ) )
               CASE ::aColumnJustify[nCol] == GRID_JTFY_RIGHT
                  oItem:setTextAlignment( hb_bitOR( Qt_AlignVCenter, Qt_AlignRight ) )
               CASE ::aColumnJustify[nCol] == GRID_JTFY_CENTER
                  oItem:setTextAlignment( hb_bitOR( Qt_AlignVCenter, Qt_AlignHCenter ) )
            ENDCASE
         ENDIF
Post Reply