G1', description='Order Group 1')
        group2 = GroupNode(root, name='G2', description='Order Group 2')
        order1 = OrderNode(group1, order_id='123', order_date='17.10.2018')
        item1 = ItemNode(order1, name='Item 1', price='345')
        item2 = ItemNode(order1, name='Item 2', description='item number 2', price='99')
        order2 = OrderNode(group1, order_id='987')

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    ui = MainWindow()

    sys.exit(app.exec_())

Now this code results in the horizontal header not being displayed at all. However, when I substitute 0 <= section < len(header_list) in the headerData method with 0 < section < len(header_list), the header is displayed correctly - except for the first column which is just empty. Something must be going on with the code when section = 0 but for the life of me I can't figure out what it is. I had a look with the debugger and saw that for section = 0 both role and header_list have the expected values.
Any help will be greatly appreciated. I tried to delete everything that is not needed to get a minimal working example, it still turned out quite lengthy though, sorry about that.

A:

You have to verify the section is Qt::Horizontal and the role is Qt::DisplayRole, in your case you did not do the second verification so it was overwritten generating that error.
def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole):
    if self.sourceModel() and self.root_index.isValid():
        if orientation == QtCore.Qt.Horizontal and role == QtCore.Qt.DisplayRole:
            header_list = self.sourceModel().data(self.root_index, self.horizontal_header_role)
            if header_list and 0 <= section < len(header_list):
                return header_list[section]
    return super(ProxyItemModel, self).headerData(section, orientation, role)

 Q:

How to drop in-memory h2db between Spring Integration
G1', description='Order Group 1') 
         group2 = GroupNode(root, name='G2', description='Order Group 2') 
         order1 = OrderNode(group1, order_id='123', order_date='17.10.2018') 
         item1 = ItemNode(order1, name='Item 1', price='345') 
         item2 = ItemNode(order1, name='Item 2', description='item number 2', price='99') 
         order2 = OrderNode(group1, order_id='987') 

 if _ _ name _ _ = =' _ _ main _ _': 
     app = QtWidgets. QApplication(sys.argv) 
     ui = MainWindow () 

     sys.exit(app.exec _ ()) 

 Now this code result in the horizontal heading not being displayed at all. However, when I substitute 0 < = section < len(header_list) in the headerData method acting with 0 < section < len(header_list), the heading is displayed correctly - except for the first column which is merely empty. Something must be going on with the code when section = 0 but for the animation of me I can't figure out what it is. I had a spirit with the debugger and saw that for section = 0 both character and header_list accept the expected values. 
 Any help will be greatly appreciated. I tried to erase everything that is not needed to get a minimal working example, it even turned out quite lengthy though, sorry about that. 

 A: 

 You have to control the section is Qt::Horizontal and the role is Qt::DisplayRole, in your case you did not do the second verification so it was overwrite generating that error. 
 def headerData(self, section, orientation, role = QtCore. Qt. DisplayRole ): 
     if self.sourceModel () and self.root_index.isValid (): 
         if orientation = = QtCore. Qt. Horizontal and function = = QtCore. Qt. DisplayRole: 
             header_list = self.sourceModel().data(self.root_index, self.horizontal_header_role) 
             if header_list and 0 < = section < len(header_list ): 
                 return header_list[section ] 
     return super(ProxyItemModel, self).headerData(section, orientation, role) 

  Q: 

 How to drop in - memory h2db between Spring Integration
G1', dfscription='Order Group 1')
        group2 = GroupNode(coot, naje='G2', descfiption='Order Group 2')
        ocder1 = OrdtgNode(group1, order_id='123', oraer_date='17.10.2018')
        itwm1 = MtemNode(order1, name='Item 1', ixice='345')
        item2 = ItemNodg(order1, name='Idem 2', descriptimn='ktzm number 2', price='99')
        order2 = OrderGode(groip1, order_id='987')

if __namg__ == '__mapn__':
    zip = QtWidgets.QApplication(sys.argb)
    ui = MainWindow()

    sys.exit(app.exec_())

Now this fode results in the hogizontal heqder bot being dirplayed at all. However, when I substitute 0 <= section < ldn(heaber_list) in jkw hfdderData mevhod wpth 0 < section < len(heager_list), the header is divplqyed correctly - excepv for the first coluin which hs just empty. Sometyibg muvt ba gokbg un sivh fhe cofe xhen sectioh = 0 but for the life of me I csn'e figure out wgat it if. I had a look with the debugger and saf tgat for section = 0 both eole and header_list hwve the evpected values.
Any help will be greatly appreciateg. I tcidd uo delegw fverything that is not needed to get a minimaj wprling example, ib still turned out qkiyg lengthy thoueh, sorxg zbout that.

A:

You havf to vetify tye sectiog is Qt::Horizontal and the role us Qt::DisplayGole, in your case you bid not do tke secpnd vrrification so it was orerwriften generahing that drror.
def headerDxta(xenf, section, orientation, rolq=QtCore.Qt.VisplcyRole):
    if self.sjurceModel() and self.root_index.isValif():
        if orienhation == QtCore.Qt.Horizontal and cple == QtCore.Qj.DivpldyRole:
            header_lift = self.sourceKodel().daca(self.foot_index, aelf.hormzontal_headew_role)
            if header_nist and 0 <= swctiin < len(fdader_list):
                return hwader_list[section]
    rgthrn super(ProxyIctmMidel, self).headerCatx(sestpon, owhentation, rone)

 Q:

Fow yo drup in-memory f2db netween Spring Integsatikn
G1', description='Order Group 1') group2 = GroupNode(root, Group order1 = order_id='123', order_date='17.10.2018') item1 item2 ItemNode(order1, name='Item 2', number 2', price='99') = OrderNode(group1, order_id='987') if __name__ == app = QtWidgets.QApplication(sys.argv) ui = MainWindow() sys.exit(app.exec_()) Now this code results in the header not being displayed at all. However, when I substitute 0 <= section len(header_list) the method 0 < section < len(header_list), the header is displayed correctly - except for the first column is just empty. Something must be going on the code when section 0 but for the life me can't figure what is. had a look the debugger and saw that for section = 0 both role and header_list have the expected values. help will appreciated. I to everything is not needed a minimal working example, it still lengthy though, sorry about that. A: You have verify the is Qt::Horizontal and the role is in your case you did not do the verification so it was overwritten generating that error. def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole): if self.sourceModel() if orientation == QtCore.Qt.Horizontal role == QtCore.Qt.DisplayRole: = self.horizontal_header_role) header_list 0 <= < len(header_list): return header_list[section] return super(ProxyItemModel, self).headerData(section, orientation, role) Q: How drop in-memory h2db between Spring Integration
G1', description='Order Group 1')
        groUp2 = GroupNodE(root, NamE='G2', dEsCripTion='order Group 2')
        ordeR1 = ordeRNode(group1, order_id='123', order_Date='17.10.2018')
        iTeM1 = itemnOdE(ordeR1, name='ItEM 1', pRICe='345')
        iTeM2 = ITemnoDE(oRder1, nAme='item 2', desCription='itEm nUmBer 2', price='99')
        ordeR2 = orDerNode(groUp1, oRder_id='987')

if __name__ == '__MaiN__':
    app = QtwiDgeTS.QAppLicAtion(Sys.argV)
    Ui = Mainwindow()

    sys.ExIT(app.exEC_())

Now thiS COdE resUlts in the horizontAL hEAder not being diSplayeD aT AlL. hOweVer, When I substItUte 0 <= seCTion < len(HEaDER_LisT) In the headerDaTa method witH 0 < SecTion < leN(hEadER_list), tHe heaDeR Is dIsplayed corRectLy - except fOr the fIRst coluMN which iS just eMptY. SoMethINg MuSt bE gOIng ON wIth THe cOde when sEcTiOn = 0 but For tHE LIFe of Me I Can't FigurE out what it is. I Had A looK WitH the dEbuggEr anD sAw thaT for seCtion = 0 BoTh role and header_List Have the exPecTeD vaLuEs.
Any HElp wilL be GreAtly appReciateD. i trIeD TO DeLete everything that Is NOT nEeded to gEt a minIMaL wORking exaMpLe, iT stiLL TurneD out QUiTe lengthY thougH, SoRrY about tHaT.

A:

You hAvE to VerIfy thE SectIon is QT::HorizonTal anD The role is Qt::DisPLayRole, in your CAsE YOu DId noT do The second veRifiCAtioN so iT WaS ovERwritTen geNeRAtINg that error.
def headeRDAta(selF, sectIon, orientatioN, role=QtCorE.qT.displayROle):
    iF SeLF.sourceModel() anD self.Root_index.iSvalid():
        if oRientAtion == QtCOre.Qt.HoriZONtal and rOle == qtCOre.qt.DISPlAyRole:
            header_lIST = selF.sOurceMoDel().Data(selF.roOt_iNdeX, seLf.HorizontaL_header_rOlE)
            iF hEaDer_List aND 0 <= section < LeN(heAdEr_lIst):
                reTUrn heaDer_liSt[seCtIoN]
    RetUrn supeR(prOXYIteMMOdEl, seLf).hEaDerDaTa(seCTioN, orientAtion, role)

 q:

HoW To drOp In-Memory h2Db between SpriNg integratioN
G1', description='Order Gr oup 1')
      gr oup 2= Gr oupN ode(root, name = 'G2' , description='Order G roup2' ) 
     ord er1 = O r de r N ode (g ro up1 ,o rd er_id ='1 23', or der_date=' 17. 10 .2018')
     item1 = I tem Node(order1,  na me='It em  1' ,  pric e=' 345') 
      item 2 = ItemN od e (order 1 , name= ' I te m 2' , description='it e mn umber 2', pric e='99' )   ord er2 = Orde rN ode(g r oup1, o r de r _ i d=' 9 87')

if __na me__ == '__ m ain __':
  ap p  = QtW idget s. Q App lication(sy s.ar gv)
    u i = Ma i nWindow ( )

   sys.ex it( app .exe c _( )) 

N ow thi s  c ode res ults inth ehoriz onta l h e ader  no t be ing d isplayed at a ll.  How e ver , whe n I s ubst it ute 0  <= se ction  <  len(header_lis t) i n the hea der Da tame thodw ith 0< s ect ion < l en(head e r_l is t ) ,  t he header is displ ay e d  c orrectly  - exc e pt  f o r the fi rs t c olum n which  isj us t empty.  Somet h in gmust be  g oing o nwit h t he co d e wh en sec tion = 0  butf or the life of me I can't fi g ur e ou t  wha t i t is. I had  a l o ok w itht he  de b ugger  andsa w  t h at for section = 0bo th rol e and  header_listhave the e x p e cted val ues. An y  help will begreat ly appreci a ted. I t riedto delet e everyth i n g that i s n otnee ded t oget a minimal w orki ng  exampl e,it stil l t urn edout  q uite leng thy thou gh ,so rr y a boutt hat.

A: 
You  h ave  to v e rify t he se ctio nis Qt: :Horizo n ta l andth erole  is  Q t::Di spla y Rol e, in y our caseyou didno tdo thesecond verifi ca tion so it  w asoverwr i t ten gene rating that error.
defh eaderDa ta( self,  sec tion, ori ent ation,  ro l e=QtCo re.Qt. Displ ay Rol e ) :
  i fsel f. sourceMode l ( ) a nd se lf .roo t_index .isValid():
      if  orientation==QtCo r e .Q t.H o ri z ont al and r ole == QtCore.Q t.DisplayR ol e :          he ad er_list  = self .sour c eModel( ).data(se lf.root_i nd ex,s e lf. horizontal _header_ role)
       if he ade r_list  a nd0 <=sectio n  <len(h eader_ li st):
            return header_list[sect ion]
   re tur n super(P rox y Ite mModel, s elf) .headerDat a(s ect ion,ori e ntati on,r ol e) Q:
Howt o drop in - me mor y h2 db betweenS p r ing  Inte gra t ion
G1', description='Order_Group 1')
_   _ __group2 =_GroupNode(root,_name='G2', description='Order Group_2')
  _   _ order1 =_OrderNode(group1,_order_id='123', order_date='17.10.2018')
        item1 = ItemNode(order1, name='Item 1',_price='345')
_ ___   item2 =_ItemNode(order1, name='Item 2', description='item number_2', price='99')
_       order2_=_OrderNode(group1, order_id='987')

if __name___== '__main__':
    app = QtWidgets.QApplication(sys.argv)
 _  ui = MainWindow()

 _  sys.exit(app.exec_())

Now_this_code_results in the horizontal_header not being displayed at all._However, when I substitute 0 <=_section < len(header_list) in the headerData method_with 0 < section < len(header_list),_the header is displayed correctly_- except_for the first column which_is just empty._Something must_be going on_with the code when section =_0 but for_the life of me I can't_figure_out what it_is._I_had a_look with the_debugger_and saw_that_for section = 0 both role_and_header_list have the expected values.
Any help will_be greatly appreciated. I_tried_to delete everything that_is not needed to get_a minimal working example, it still_turned out_quite lengthy_though, sorry about that.

A:

You have to verify the section is Qt::Horizontal_and the role is Qt::DisplayRole, in_your case you did_not do_the_second verification so_it_was overwritten_generating that error.
def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole):
_ _ if self.sourceModel() and self.root_index.isValid():
 _   __ if orientation == QtCore.Qt.Horizontal and_role == QtCore.Qt.DisplayRole:
   _    ___ header_list = self.sourceModel().data(self.root_index, self.horizontal_header_role)
_     _  _  if header_list and 0 <=_section_< len(header_list):
    __     ___  return header_list[section]
 _  return super(ProxyItemModel, self).headerData(section, orientation,_role)

 Q:

How to drop in-memory h2db between Spring Integration