show/hide dockWidget

Discussion forum for contributors and developers who are using the QCAD ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Post Reply
Registered Member
Posts: 1
Joined: Wed Dec 06, 2017 7:07 pm

show/hide dockWidget

Post by oumla » Wed Dec 06, 2017 8:03 pm


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 () {;


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

  //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 !

Post Reply

Return to “QCAD Developers and Contributors”