author | wesleyt@symbian.org |
Thu, 09 Sep 2010 11:30:41 -0700 | |
changeset 45 | b23ec2b62c45 |
parent 44 | ca3ea89c80a3 |
child 46 | 702dd26c0f4d |
permissions | -rwxr-xr-x |
42
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
1 |
#include <QMenuBar> |
45 | 2 |
#include <QMessageBox> |
3 |
#include <QResizeEvent> |
|
4 |
#include <QtGlobal> |
|
42
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
5 |
|
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
6 |
#include "mainwindow.h" |
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
7 |
#include "ui_mainwindow.h" |
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
8 |
#include "zodiacmodel.h" |
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
9 |
#include "zodiacdelegate.h" |
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
10 |
|
45 | 11 |
|
42
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
12 |
MainWindow::MainWindow(QWidget *parent) : |
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
13 |
QMainWindow(parent), |
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
14 |
ui(new Ui::MainWindow) |
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
15 |
{ |
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
16 |
ui->setupUi(this); |
44 | 17 |
|
45 | 18 |
// Create widgets. |
19 |
listView = new QListView; |
|
20 |
listView->setFrameStyle(QFrame::Panel | QFrame::Raised); |
|
21 |
listView->setLineWidth(4); |
|
22 |
exitButton = new QPushButton(this); |
|
23 |
exitButton->setText("Exit"); |
|
24 |
||
25 |
// define the model |
|
42
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
26 |
ZodiacModel *zModel = new ZodiacModel(this); |
45 | 27 |
listView->setModel(zModel); |
42
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
28 |
ZodiacDelegate *delegate = new ZodiacDelegate(this); |
45 | 29 |
listView->setItemDelegate(delegate); |
30 |
||
31 |
// create landscape layout |
|
32 |
layoutLandscape = new QHBoxLayout(this); |
|
33 |
layoutLandscape->addWidget(listView); |
|
34 |
layoutLandscape->addWidget(exitButton); |
|
35 |
||
36 |
//create portrait layout |
|
37 |
layoutPortrait = new QVBoxLayout(this); |
|
38 |
layoutPortrait->addWidget(listView); |
|
39 |
layoutPortrait->addWidget(exitButton); |
|
40 |
||
41 |
portLandLayout = new PLLayout(); |
|
42 |
portLandLayout->setPLayout(layoutPortrait); |
|
43 |
portLandLayout->setLLayout(layoutLandscape); |
|
44 |
||
45 |
centralWidget = new QWidget(); |
|
46 |
centralWidget->setLayout(portLandLayout); |
|
47 |
this->setCentralWidget(centralWidget); |
|
48 |
||
42
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
49 |
} |
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
50 |
|
45 | 51 |
|
42
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
52 |
MainWindow::~MainWindow() |
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
53 |
{ |
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
54 |
delete ui; |
b9716e8867f1
checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
55 |
} |
45 | 56 |
|
57 |
void MainWindow::resizeEvent(QResizeEvent *e) |
|
58 |
{ |
|
59 |
portLandLayout->resizeEvent(e); |
|
60 |
// Call base class impl |
|
61 |
QWidget::resizeEvent(e); |
|
62 |
} |