main.cpp:
#include <QApplication>
#include <QtGui>
#include "testlist.h"
int main(int argc, char*argv[])
{
TestList *t = new TestList();
t->show();
return app.exec();
}
#include <QApplication>
#include <QtGui>
#include "testlist.h"
int main(int argc, char*argv[])
{
QApplication app (argc,argv);
TestList *t = new TestList();
t->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
testlist.h:
#ifndef TESTLIST_H
#define TESTLIST_H
#include <QListWidget>
#include <QListWidgetItem>
#include <QHBoxLayout>
#include <QDialog>
#include <QMessageBox>
{
Q_OBJECT
public:
{
mList->addItem("Walmart");
mList->addItem("Ford Motors");
mList->addItem("Circuit City");
h->addWidget( mList );
setLayout(h);
}
public slots:
{
t->setText (m->text() );
t->exec();
}
};
#endif // TESTLIST_H
#ifndef TESTLIST_H
#define TESTLIST_H
#include <QListWidget>
#include <QListWidgetItem>
#include <QHBoxLayout>
#include <QDialog>
#include <QMessageBox>
class TestList : public QDialog
{
Q_OBJECT
public:
TestList( QWidget *parent = 0 ):
QDialog( parent )
{
QListWidget *mList = new QListWidget(this);
mList->addItem("Walmart");
mList->addItem("Ford Motors");
mList->addItem("Circuit City");
QHBoxLayout *h = new QHBoxLayout();
h->addWidget( mList );
setLayout(h);
connect( mList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(test(QListWidgetItem*)));
}
public slots:
void test( QListWidgetItem *m )
{
QMessageBox *t = new QMessageBox( this );
t->setText (m->text() );
t->exec();
}
};
#endif // TESTLIST_H
To copy to clipboard, switch view to plain text mode
Bookmarks