Couple of Qt Questions.

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Couple of Qt Questions.

Post by openBrain »

keithsloan52 wrote: Fri May 28, 2021 8:24 am Has something to do with if I close the task panel and go back in it no longer updates the Vertex and Facets info.
Is it close or hide ? If you really close you don't have your widgets anymore.
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Couple of Qt Questions.

Post by keithsloan52 »

openBrain wrote: Fri May 28, 2021 8:34 am
keithsloan52 wrote: Fri May 28, 2021 8:24 am Has something to do with if I close the task panel and go back in it no longer updates the Vertex and Facets info.
Is it close or hide ? If you really close you don't have your widgets anymore.
Its the close button or the result of a leave being driven and your suggestion of how to close.
"you don't have your widgets anymore" Well No, the widgets are there when I reopen, just not with the last updates before leave is driven
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Couple of Qt Questions.

Post by keithsloan52 »

My panel looks like
42636CC0-5872-42ED-89B1-8634D0765B44.jpeg
42636CC0-5872-42ED-89B1-8634D0765B44.jpeg (54.02 KiB) Viewed 1285 times
And the leaveEvent gets drive when my mouse leaves apart from if I exit to the sides anywhere above the title 'Tessellate with Gmsh' How can I fix this?
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Couple of Qt Questions.

Post by openBrain »

What's the code ?
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Couple of Qt Questions.

Post by keithsloan52 »

openBrain wrote: Fri Jun 18, 2021 11:55 am What's the code ?
Sorry thought I had already posted it, but it has changed a bit since then

Code: Select all

class AddTessellateWidget(QtGui.QWidget):
    def __init__(self, Shape,*args):
        QtGui.QWidget.__init__(self,*args)
        bboxGroup  = QtGui.QGroupBox('Objects Bounding Box')
        laybbox = QtGui.QHBoxLayout()
        laybbox.addWidget(QtGui.QLabel('Width : '+str(Shape.BoundBox.XLength)))
        laybbox.addWidget(QtGui.QLabel('Height : '+str(Shape.BoundBox.YLength)))
        laybbox.addWidget(QtGui.QLabel('Depth : '+str(Shape.BoundBox.ZLength) ))
        bboxGroup.setLayout(laybbox)
        maxl = int((Shape.BoundBox.XLength + Shape.BoundBox.YLength + \
                    Shape.BoundBox.ZLength) / 15)
        self.type     = QtGui.QComboBox()
        self.type.addItems(['Triangular','Quadrangular','Parallelograms'])
        self.group    = QtGui.QGroupBox('Mesh Characteristics')
        self.maxLen   = iField('Max Length',5,str(maxl))
        self.curveLen = iField('Curve Length',5,'10')
        self.pointLen = iField('Length from Point',5,'10')
        self.Vertex   = oField('Vertex',6,'')
        self.Facets   = oField('Facets',6,'')
        self.meshParmsLayout=QtGui.QGridLayout()
        self.meshParmsLayout.addWidget(self.type,0,0)
        self.meshParmsLayout.addWidget(self.maxLen,0,1)
        self.meshParmsLayout.addWidget(self.curveLen,1,0)
        self.meshParmsLayout.addWidget(self.pointLen,1,1)
        self.group.setLayout(self.meshParmsLayout)
        self.buttonMesh = QtGui.QPushButton(translate('GDML','Mesh'))
        layoutAction=QtGui.QHBoxLayout()
        layoutAction.addWidget(self.buttonMesh)
        self.Vlayout= QtGui.QVBoxLayout()
        self.Vlayout.addWidget(bboxGroup)
        self.Vlayout.addWidget(self.group)
        self.Vlayout.addLayout(layoutAction)
        self.setLayout(self.Vlayout)
        self.setWindowTitle(translate('GDML','Tessellate with Gmsh'))

    def leaveEvent(self, event) :
        print('Leave Event')

openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Couple of Qt Questions.

Post by openBrain »

I had a quick test by tweaking the code to have the widget display as a dialog and it works fine.
Maybe something is preempting the event when placed in Task panel...
Post Reply