Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. deleting and redraw new buttons
Forum Updated to NodeBB v4.3 + New Features

deleting and redraw new buttons

Scheduled Pinned Locked Moved Solved Qt for Python
5 Posts 2 Posters 694 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chabis
    wrote on last edited by chabis
    #1

    hello,
    i'm new on QT, and i work (for blender), to have a character picker.
    for each part of my character, i create a button to select it.
    so because i have potentially several character, with some special parts (like dress or short) i create a button to delete and re-create buttons for selecting parts. deleting is ok, recreate seem working well, but no (new) buttons are visibles. and i don't understand why. i try several things, but nothing...

    my init part:

        def init_ui(self):
            # layout general
            self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
            ###------------------------------------------------------###
            #self.verticalLayout = QtWidgets.QVBoxLayout(self)
            #self.verticalLayout.setObjectName('verticalLayout')
    
            self.topLeftLayout = QtWidgets.QWidget(self)
            self.topLeftLayout.setGeometry(QtCore.QRect(0, 0, 300, 200))
            self.topLeftLayout.setObjectName("topLeftLayout")
    
            self.topMiddleLayout = QtWidgets.QWidget(self)
            self.topMiddleLayout.setGeometry(QtCore.QRect(300, 0, 300, 200))
            self.topMiddleLayout.setObjectName("topMiddleLayout")
    
            self.topRightLayout = QtWidgets.QWidget(self)
            self.topRightLayout.setGeometry(QtCore.QRect(600, 0, 300, 200))
            self.topRightLayout.setObjectName("topRightLayout")
    
            self.pantinLayout = QtWidgets.QWidget(self)
            self.pantinLayout.updatesEnabled()
            self.pantinLayout.setGeometry(QtCore.QRect(250, 200, 500, 600))
            self.pantinLayout.setObjectName("topRightLayout")
    
            ###-------------------------------------------------------###
            self.Radio_obj_name = QtWidgets.QPushButton("update character", parent=self.topLeftLayout)
            self.Radio_obj_name.setObjectName(u"pushButton")
            self.Radio_obj_name.setGeometry(QtCore.QRect(10, 10, 120, 23))
            self.Radio_obj_name.setCheckable(True)
    
            ###-------------------------------------------------------###
    
            self.butgroup = QtWidgets.QButtonGroup(self)
            self.createPantin()
            self.Radio_obj_name.clicked.connect(self.change_character)
    

    the creation part for character buttons

        def createPantin(self):
            if len(bpy.context.view_layer.objects.selected) > 0:
                sel = bpy.context.view_layer.objects.selected[0]
                if sel.type == 'ARMATURE':
                    print("parla")
                    self.pantpart = []
    
                    # creation des switch
                    for i in self.swt:
                        if i in self.layers:
                            self.createSwitch(i)
                    # creation du pantin
                    for i in self.bmps:
                        for j in self.buttons:
                            for k in self.buttons[j]:
                                if i == k:
                                    name = self.bmpPath+i+".png"
                                    self.path = name.replace("\\","/")
                                    self.but = QtWidgets.QPushButton("", parent=self.pantinLayout)
                                    self.but.setAccessibleName(j+"/"+i)
                                    self.but.setGeometry(
                                                        (self.bmps[i][0]/self.ratio)-self.Hoffset,
                                                        (self.bmps[i][1]/self.ratio)-self.Voffset,
                                                        self.bmps[i][2]/self.ratio,
                                                        self.bmps[i][3]/self.ratio
                                                        )
                                    self.but.setStyleSheet("QPushButton{image:url("+self.path+"); border:none}")
                                    self.butgroup.addButton(self.but)
                                    self.pantpart.append(self.but)
    
    
                    # connection bouton
                    self.butgroup.buttonClicked.connect(self.selectpart)                
    

    and the code called by the button to update

        def change_character(self):
            #self.verticalLayout.removeWidget(self.pantinLayout)
            #self.pantinLayout.deleteLater()
            for i in self.pantpart:
                i.deleteLater()
    
            self.characterID()
            self.organize()
            self.createPantin()
            for i in self.pantpart:
                i.repaint()
                i.update()
    

    if someone could explain me what i don't understand

    jsulmJ 1 Reply Last reply
    0
    • C chabis

      hello,
      i'm new on QT, and i work (for blender), to have a character picker.
      for each part of my character, i create a button to select it.
      so because i have potentially several character, with some special parts (like dress or short) i create a button to delete and re-create buttons for selecting parts. deleting is ok, recreate seem working well, but no (new) buttons are visibles. and i don't understand why. i try several things, but nothing...

      my init part:

          def init_ui(self):
              # layout general
              self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
              ###------------------------------------------------------###
              #self.verticalLayout = QtWidgets.QVBoxLayout(self)
              #self.verticalLayout.setObjectName('verticalLayout')
      
              self.topLeftLayout = QtWidgets.QWidget(self)
              self.topLeftLayout.setGeometry(QtCore.QRect(0, 0, 300, 200))
              self.topLeftLayout.setObjectName("topLeftLayout")
      
              self.topMiddleLayout = QtWidgets.QWidget(self)
              self.topMiddleLayout.setGeometry(QtCore.QRect(300, 0, 300, 200))
              self.topMiddleLayout.setObjectName("topMiddleLayout")
      
              self.topRightLayout = QtWidgets.QWidget(self)
              self.topRightLayout.setGeometry(QtCore.QRect(600, 0, 300, 200))
              self.topRightLayout.setObjectName("topRightLayout")
      
              self.pantinLayout = QtWidgets.QWidget(self)
              self.pantinLayout.updatesEnabled()
              self.pantinLayout.setGeometry(QtCore.QRect(250, 200, 500, 600))
              self.pantinLayout.setObjectName("topRightLayout")
      
              ###-------------------------------------------------------###
              self.Radio_obj_name = QtWidgets.QPushButton("update character", parent=self.topLeftLayout)
              self.Radio_obj_name.setObjectName(u"pushButton")
              self.Radio_obj_name.setGeometry(QtCore.QRect(10, 10, 120, 23))
              self.Radio_obj_name.setCheckable(True)
      
              ###-------------------------------------------------------###
      
              self.butgroup = QtWidgets.QButtonGroup(self)
              self.createPantin()
              self.Radio_obj_name.clicked.connect(self.change_character)
      

      the creation part for character buttons

          def createPantin(self):
              if len(bpy.context.view_layer.objects.selected) > 0:
                  sel = bpy.context.view_layer.objects.selected[0]
                  if sel.type == 'ARMATURE':
                      print("parla")
                      self.pantpart = []
      
                      # creation des switch
                      for i in self.swt:
                          if i in self.layers:
                              self.createSwitch(i)
                      # creation du pantin
                      for i in self.bmps:
                          for j in self.buttons:
                              for k in self.buttons[j]:
                                  if i == k:
                                      name = self.bmpPath+i+".png"
                                      self.path = name.replace("\\","/")
                                      self.but = QtWidgets.QPushButton("", parent=self.pantinLayout)
                                      self.but.setAccessibleName(j+"/"+i)
                                      self.but.setGeometry(
                                                          (self.bmps[i][0]/self.ratio)-self.Hoffset,
                                                          (self.bmps[i][1]/self.ratio)-self.Voffset,
                                                          self.bmps[i][2]/self.ratio,
                                                          self.bmps[i][3]/self.ratio
                                                          )
                                      self.but.setStyleSheet("QPushButton{image:url("+self.path+"); border:none}")
                                      self.butgroup.addButton(self.but)
                                      self.pantpart.append(self.but)
      
      
                      # connection bouton
                      self.butgroup.buttonClicked.connect(self.selectpart)                
      

      and the code called by the button to update

          def change_character(self):
              #self.verticalLayout.removeWidget(self.pantinLayout)
              #self.pantinLayout.deleteLater()
              for i in self.pantpart:
                  i.deleteLater()
      
              self.characterID()
              self.organize()
              self.createPantin()
              for i in self.pantpart:
                  i.repaint()
                  i.update()
      

      if someone could explain me what i don't understand

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @chabis Call show() on each created button.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • C Offline
        C Offline
        chabis
        wrote on last edited by
        #3

        humm... i've try but nothing change.
        ... it's a mystery for me

        jsulmJ 1 Reply Last reply
        0
        • C chabis

          humm... i've try but nothing change.
          ... it's a mystery for me

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @chabis Did you debug your code? Did you verify that buttons were indeed created? Did you verify whether you set proper geometry (not sure why you do that at all)?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • C Offline
            C Offline
            chabis
            wrote on last edited by
            #5

            yes , i've done all i can, and finally it's ok.
            and the problems seem to be in the widget where i put my buttons. all was create correctly but nothing was visible. i 've changed the kind of widget i use, and now it's ok.
            (i need to say that not is clear in my mind about how qt is working.)

            thanks for all @jsulm

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved