Dialog window help

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
kdwoll
Junior Member
Posts: 12
Joined: Wed Oct 26, 2022 12:51 pm

Dialog window help

Post by kdwoll » Tue Nov 12, 2024 3:05 pm

On a dialog window, why do all the buttons show up instead of just the selected ones.
dialog.png
dialog.png (20.48 KiB) Viewed 49398 times
In the Qt Creature I have just the ok button and close button selected.
this is all the code in the dialog window.


Code: Select all

// Include base class definition:
include("../nTruss.js");
// Constructor calls base class constructor:
function nTrussOptions(guiAction) {
    nTruss.call(this, guiAction);
}
// Derive class nTrussOptions from class nTruss:
nTrussOptions.prototype = new nTruss();
nTrussOptions.includeBasePath = includeBasePath;
nTrussOptions.prototype.beginEvent = function() {
    nTruss.prototype.beginEvent.call(this);
    // Create the dialog from the .ui file using the helper function WidgetFactory.createWidget().
    var dialog = WidgetFactory.createWidget(nTrussOptions.includeBasePath,"nTrussOptions.ui");
    // Restore the previous user data or display default values as set in Qt Designer:
    WidgetFactory.restoreState(dialog);
		// Display and execute the dialog:
		if (!dialog.exec()) {
			dialog.destroy();
			EAction.activateMainWindow();
			// User hit cancel:
			this.terminate();
			return;
		}
    dialog.destroy();
    EAction.activateMainWindow();
    this.terminate();
};
//! [beginEvent]
// nTrussOptions.init() is called by QCAD to initialize the action and create
// the menu / toolbar for it.
nTrussOptions.init = function(basePath) {
    var action = new RGuiAction("Truss &Options", RMainWindowQt.getMainWindow());
    action.setScriptFile(basePath + "/nTrussOptions.js");
    action.setIcon(basePath + "/nTrussOptions.svg");
    action.setDefaultCommands(["Nailing Pattern Options"]);
     action.setGroupSortOrder(50);
    action.setSortOrder(1);
    action.setWidgetNames(["nTrussMenu"]);
}; 	    

CVH
Premier Member
Posts: 4919
Joined: Wed Sep 27, 2017 4:17 pm

Re: Dialog window help

Post by CVH » Tue Nov 12, 2024 3:31 pm

kdwoll wrote:
Tue Nov 12, 2024 3:05 pm
In the Qt Creature I have just the ok button and close button selected.
You probably mean Qt Designer ...

Supposing that all those widgets are part of the nTrussOptions.ui file.
When you save a UI file in Qt Designer it saves not only the selected, it saves all existent widgets.

PS: I hope that you have seen this issue

To delete them you must actually delete them in the designing stage.
Or hide them once the dialog is generated.

Regards,
CVH

CVH
Premier Member
Posts: 4919
Joined: Wed Sep 27, 2017 4:17 pm

Re: Dialog window help

Post by CVH » Tue Nov 12, 2024 6:11 pm

However ....
The list of commands on your widgets resembles the QDialogButtonBox::StandardButton list

As if a button was created for every type of standard buttons ...

Regards,
CVH

kdwoll
Junior Member
Posts: 12
Joined: Wed Oct 26, 2022 12:51 pm

Re: Dialog window help

Post by kdwoll » Wed Nov 13, 2024 5:13 am

this issue is really old. I'm many versions beyond that. I might upload the final product.

It seemed to fix when I used Qt designer instead of Qt creator. so all good there.\\

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”