PDA

View Full Version : Passing Ui files as parameter



hgedek
12th December 2007, 07:49
I have two Ui objects in my class header.I know that the Ui classes dont inherit form QObject.But I want to pass these objects to a function.Dynamically It will work.Question:Is there a way of passing these two different class objects?(Ex:QPushButton and QLabel.... can be passed as QWidget...)

jpn
12th December 2007, 09:10
Different Ui classes have nothing in common. But for them to be usable, you'll need to load them to a widget anyway. So basically you could load them to corresponding widgets and pass them to your function. But may I ask, what do you actually intend to do? Could you describe what's the purpose of the function?

high_flyer
12th December 2007, 09:17
you might want to have a look at QUiLoader, maybe it will help you achieve what you want.

hgedek
12th December 2007, 12:14
I have a form and a dialog.Both of them has same widgets(LineEdits,Labels...).Reading Id's from XML I am showing informations of objects on form and dialog.But If user wants to change values of objects he will use dialog.So I have two UI objects.Form and dialog objects .And they have same functions...If I could pass UI objects dynamically I can write some functions once.

void ProgramEditor::CreateEditorPointMenu()
{
int countOfCom,countOfLabel;
QString InputWidget;

CommandList.clear();
Data::ReadTypeList(commandNumber,CommandList);
InputWidget=CommandList[0];
countOfCom=InputWidget.count("1");
countOfLabel=0;
openWidgets.clear();

switch(countOfCom)
{
case 4:
countOfLabel=4;
SetPointMenuArrange(countOfLabel,UIeditor->label_4,UIeditor->lineEdit_4);
case 3:
if(countOfLabel==0)
countOfLabel=3;
SetPointMenuArrange(countOfLabel,UIeditor->label_3,UIeditor->lineEdit_3);
case 2:
if(countOfLabel==0)
countOfLabel=2;
SetPointMenuArrange(countOfLabel,UIeditor->label_2,UIeditor->lineEdit_2);
case 1:
if(countOfLabel==0)
countOfLabel=1;
SetPointMenuArrange(countOfLabel,UIeditor->label_1,UIeditor->lineEdit_1);
break;
default:
break;
}
countOfCom=0;
countOfCom=InputWidget.count("2");
switch(countOfCom)
{
case 2:
SetPointMenuItems(UIeditor->label_6,UIeditor->comboBox_2,CommandList[countOfLabel+2]);

case 1:
SetPointMenuItems(UIeditor->label_5,UIeditor->comboBox_1,CommandList[countOfLabel+1]);
break;

default:
break;
}
countOfCom=0;
countOfCom=InputWidget.count("3");
switch(countOfCom)
{
case 2:
if(UIeditor->checkBox_2->isVisible()==false)
{
UIeditor->checkBox_2->setVisible(true);
openWidgets.push_back(UIeditor->checkBox_2);
}
case 1:
if(UIeditor->checkBox_1->isVisible()==false)
{
UIeditor->checkBox_1->setVisible(true);
openWidgets.push_back(UIeditor->checkBox_1);
}
break;
default:
break;
}

}

void ProgramEditor::CreateSetPointEditor()
{
int countOfCom,countOfLabel;
QString InputWidget;

CommandList.clear();
Data::ReadTypeList(commandNumber,CommandList);
InputWidget=CommandList[0];
countOfCom=InputWidget.count("1");
countOfLabel=0;
openWidgets.clear();

switch(countOfCom)
{
case 4:
countOfLabel=4;
SetPointMenuArrange(countOfLabel,UIsetPoint->label_4,UIsetPoint->lineEdit_4,
UIeditor->lineEdit_4,true);
case 3:
if(countOfLabel==0)
countOfLabel=3;
SetPointMenuArrange(countOfLabel,UIsetPoint->label_3,UIsetPoint->lineEdit_3,
UIeditor->lineEdit_3,true);
case 2:
if(countOfLabel==0)
countOfLabel=2;
SetPointMenuArrange(countOfLabel,UIsetPoint->label_2,UIsetPoint->lineEdit_2,
UIeditor->lineEdit_2,true);
case 1:
if(countOfLabel==0)
countOfLabel=1;
SetPointMenuArrange(countOfLabel,UIsetPoint->label_1,UIsetPoint->lineEdit_1,
UIeditor->lineEdit_1,true);
break;
default:
break;
}
countOfCom=0;
countOfCom=InputWidget.count("2");
switch(countOfCom)
{
case 2:
SetPointMenuItems(UIsetPoint->label_6,UIsetPoint->comboBox_2,CommandList[countOfLabel+2]);
case 1:
SetPointMenuItems(UIsetPoint->label_5,UIsetPoint->comboBox_1,CommandList[countOfLabel+1]);
break;

default:
break;
}
countOfCom=0;
countOfCom=InputWidget.count("3");
switch(countOfCom)
{
case 2:
if(UIsetPoint->checkBox_2->isVisible()==false)
{
UIsetPoint->checkBox_2->setVisible(true);
openWidgets.push_back(UIsetPoint->checkBox_2);
}
case 1:
if(UIsetPoint->checkBox_1->isVisible()==false)
{
UIsetPoint->checkBox_1->setVisible(true);
openWidgets.push_back(UIsetPoint->checkBox_1);
}
break;
default:
break;
}
}