Page 1 of 1

show/hide dockWidget

Posted: Wed Dec 06, 2017 8:03 pm
by oumla
Hi,

I have a widget associeted to Line2P tool, and I want to dock it when Line2P is activated, otherwise hide it :
I tried to do like this :

Code: Select all

Line2P.prototype.beginEvent = function () {
  Line.prototype.beginEvent.call(this);

  this.setState(Line2P.State.SettingFirstPoint);
  this.updateButtonStates();

  //dock widget
  var appWin = RMainWindowQt.getMainWindow();
  if (isNull(appWin.findChild("LinePolygoneDock"))) {
    var formWidget = WidgetFactory.createWidget(Line2P.includeBasePath, "LinePolygone.ui");
    WidgetFactory.restoreState(formWidget);
    var dock = new RDockWidget(qsTr("Clavier - Dessin"), appWin);
    dock.objectName = "LinePolygoneDock";
    //dock.setProperty("Category", Widgets.getListContextMenuCategory());
    dock.setWidget(formWidget);
    appWin.addDockWidget(Qt.RightDockWidgetArea, dock);
  }
  else {
    var dock = appWin.findChild("LinePolygoneDock");
    dock.visible = true;
    dock.raise();
  }

  //set action
  dock.findChild("btnTlRight").clicked.connect(this, "drawLineDirectionRight");
}; 

Line2P.prototype.finishEvent = function () {
  var appWin = RMainWindowQt.getMainWindow();
  var dock = appWin.findChild("LinePolygoneDock");
  dock.visible = false;
  //TOOD : handling with the right way disconnect events
  dock.findChild("btnTlRight").clicked.disconnect(this, "drawLineDirectionRight");
};
But I have trouble with disconnect events :
-disconnect doesn't work properly (I see, if I reset and return to tool, the action "drawLineDirectionRight" is called many times).

other question reated:
if my method "drawLineDirectionRight" take an argument, how can I pass it with :

Code: Select all

dock.findChild("btnPolRight").clicked.connect(this, "drawLineDirectionRight");
Thanks for your help in advance !