show/hide dockWidget

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

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
oumla
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

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 !

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”