const Router = require('express').Router;
// const router = new Router(); // <--- move this line ...
module.exports = (model) => {
return (db) => {
const router = new Router(); // <--- ... to here
router.post('/', (req, res, next) => {
console.log(model.modelName);
model.insertMany(req.body, (err, docs) => {
if(err) return next(err);
res.json(docs);
});
});
return router;
};
};
当我点击系列按钮时,我想删除家庭模块中显示的小部件,当我点击主页按钮时,删除系列模块中的小部件。 到目前为止发生的事情是,当我点击系列按钮时,他以前来自家庭模块的小部件仍在那里。
答案 0 :(得分:1)
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
import sys
class Window(QMainWindow):
def __init__(self):
super(Window, self).__init__()
self.widget =QWidget()
self.layout = QHBoxLayout()
self.widget.setLayout(self.layout)
self.setCentralWidget(self.widget)
self.tabs()
def home(self):
self.clear()
self.df1 = QPushButton('hello')
self.layout.addWidget(self.df1)
def series(self):
self.clear()
self.df2 = QCheckBox('hello')
self.layout.addWidget(self.df2)
def tabs(self):
self.btn_home = QPushButton(QIcon('home.png'), 'Home')
self.btn_home.clicked.connect(self.home)
self.layout.addWidget(self.btn_home)
self.btn_series = QPushButton(QIcon('series.png'),'Series')
self.btn_series.clicked.connect(self.series)
self.layout.addWidget(self.btn_series)
self.show()
def clear(self):
item = self.layout.itemAt(2)
if item != None :
widget = item.widget()
if widget != None:
self.layout.removeWidget(widget)
widget.deleteLater()
def run():
app = QApplication(sys.argv)
GUI = Window()
sys.exit(app.exec_())
if __name__ == '__main__': run()
答案 1 :(得分:0)
我的版本是
self.main_canvas.children().remove(cogmapui)
cogmapui.deleteLater()
我通过在cogmapui的print("Deleted")
函数中放入__del__
进行检查,是的,它被调用了。