Well, the project use QMainWindow. I show you the code:
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
{
Q_OBJECT
public:
explicit MainWindow
(QWidget *parent
= 0);
~MainWindow();
private:
Ui::MainWindow *ui;
private slots:
void on_pushButton_clicked();
};
#endif // MAINWINDOW_H
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
private slots:
void on_pushButton_clicked();
};
#endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode
main.cpp
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
MainWindow2 w;
#if defined(Q_WS_S60)
w.showMaximized();
#else
w.show();
#endif
return a.exec();
}
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow2 w;
#if defined(Q_WS_S60)
w.showMaximized();
#else
w.show();
#endif
return a.exec();
}
To copy to clipboard, switch view to plain text mode
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtGui>
#include "ListviewDelegate.h"
ListviewDelegate *listdelegate;
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
listdelegate = new ListviewDelegate();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
ui->listView->setItemDelegate(listdelegate);
ui->listView->setModel(model);
item->setData("InBox",ListviewDelegate::headerTextRole);
item->setData("10 messages",ListviewDelegate::subHeaderTextrole);
item->setData("Hola que tal aixo es una prova jfhjklsd jfdlañj fklañjf lakñfj aklj fadklñfj aklfj aklj falñ",ListviewDelegate::rightTextRole);
model->appendRow(item);
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtGui>
#include "ListviewDelegate.h"
QStandardItemModel *model;
ListviewDelegate *listdelegate;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
model = new QStandardItemModel();
listdelegate = new ListviewDelegate();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
ui->listView->setItemDelegate(listdelegate);
ui->listView->setModel(model);
QStandardItem *item = new QStandardItem();
item->setData("InBox",ListviewDelegate::headerTextRole);
item->setData("10 messages",ListviewDelegate::subHeaderTextrole);
item->setData("Hola que tal aixo es una prova jfhjklsd jfdlañj fklañjf lakñfj aklj fadklñfj aklfj aklj falñ",ListviewDelegate::rightTextRole);
model->appendRow(item);
}
To copy to clipboard, switch view to plain text mode
Thank youuu!!
Bookmarks