Thanks. That did the job.
I am able to create a dialog using qcreator and use it my program.
one thing though I could not get the degree symbol in the text for the radiobutton using unicode
I was actually trying to create a dialog programmatically.
Please check the following code. (I am just curious to make this work)
What should I do to get the chosen index from combo box and the state of the radio button and close the dialog when the push button is clicked.
Code: Select all
function InsertBlockDialog() {
this.choice = 0;
this.angle = 0;
this.blocks = new Array("Cell", "Capacitor", "Inductor", "Resistor", "AC", "Instr", "Terminal");
var dialog = new QDialog(RMainWindowQt.getMainWindow());
var vbl = new QVBoxLayout();
var RBW = new QWidget();
var RBLO = new QHBoxLayout();
var RBWL = new QLabel("Value :");
RBLO.addWidget(RBWL, 0, 0);
RBW.setLayout(RBLO);
vbl.addWidget(RBW, 0, 0);
var comboBox = new QComboBox();
for (var i = this.blocks.length - 1; i >= 0; --i) {
comboBox.insertItem(0, this.blocks[i]);
}
var pb = new QPushButton("Done", dialog);
var rb1 = new QRadioButton("0\u00B0");
rb1.checked = true;
var rb2 = new QRadioButton( "90\u00B0");
var rb3 = new QRadioButton("180\u00B0");
var rb4 = new QRadioButton("270\u00B0");
var RBW = new QWidget();
var RBLO = new QHBoxLayout();
var RBL = new QLabel("Angle :");
RBLO.addWidget(RBL, 0, 0);
RBLO.addWidget(rb1, 0, 0);
RBLO.addWidget(rb2, 0, 0);
RBLO.addWidget(rb3, 0, 0);
RBLO.addWidget(rb4, 0, 0);
RBW.setLayout(RBLO);
vbl.addWidget(RBW, 0, 0);
RBW.setLayout(RBLO);
var dialogLayout = new QVBoxLayout();
dialogLayout.addWidget(comboBox, 0, 0)
dialogLayout.addWidget(RBW, 0, 0);
dialogLayout.addWidget(pb, 0, 0);
dialog.setLayout(dialogLayout);
dialog.setWindowTitle("::: Block :::");
pb.clicked.connect(function () {
this.choice = comboBox.currentIndex;
if (rb1.checked)
this.angle = 0;
else if (rb2.checked)
this.angle = 90;
else if (rb3.checked)
this.angle = 180;
else if (rb4.checked)
this.angle = 270;
});
dialog.exec();
};