30 #include <QtGui/QApplication>
33 : QWidget(parent, flags)
36 connect(ui.comboBox, SIGNAL(currentIndexChanged(
int)),
this, SLOT(select(
int)));
41 m_entries.append(obj);
42 ui.comboBox->addItem(obj->
title());
45 void MyMain::select(
int index)
50 IText1 *t1 = Aggregation::query<IText1>(entry);
51 IText2 *t2 = Aggregation::query<IText2>(entry);
52 IText3 *t3 = Aggregation::query<IText3>(entry);
55 ui.text1->setText(t1 ? t1->
text() : tr(
"N/A"));
56 ui.text2->setText(t2 ? t2->text() : tr(
"N/A"));
57 ui.text3->setText(t3 ? t3->text() : tr(
"N/A"));
58 ui.text1->setEnabled(t1);
59 ui.text2->setEnabled(t2);
60 ui.text3->setEnabled(t3);
67 qDeleteAll(m_entries);
70 int main(
int argc,
char *argv[])
72 QApplication app(argc, argv);
84 obj2->
add(
new IText2(
"This is a text for label 2"));
90 obj3->
add(
new IText2(
"There are software companies..."));
93 obj4->
add(
new IText1(
"Some text written here."));
98 w.
add(Aggregation::query<IComboEntry>(obj1));
99 w.
add(Aggregation::query<IComboEntry>(obj2));
100 w.
add(Aggregation::query<IComboEntry>(obj3));
101 w.
add(Aggregation::query<IComboEntry>(obj4));
void add(IComboEntry *obj)
int main(int argc, char *argv[])
Defines a collection of related components that can be viewed as a unit.
void add(QObject *component)
MyMain(QWidget *parent=0, Qt::WFlags flags=0)