PDA

View Full Version : go next screen



sabbu
27th April 2011, 08:04
i have been create a listwidget and add three items i want when touch on item then open new screen.but i can't success please help me i send the code
////////////////header//////////


#ifndef MYWIDGET_H
#define MYWIDGET_H

#include <QWidget>
#include<QtGui>
namespace Ui {
class MyWidget;
}
class QListWidget;
class QListWidgetItem;
class MyWidget : public QWidget
{
Q_OBJECT

public:
explicit MyWidget(QWidget *parent = 0);
~MyWidget();
private slots:
void itemClicked(QListWidgetItem *item);

private:

QListWidget *m_myListWidget;
QPushButton *widget2;
QPushButton *widget3;



};

#endif // MYWIDGET_H
/////////////////////cpp////////////////

#include "mywidget.h"
#include "ui_mywidget.h"

MyWidget::MyWidget(QWidget *parent) :
QWidget(parent)

{

m_myListWidget = new QListWidget(this);
new QListWidgetItem(tr("shahid"), m_myListWidget);
// new QListWidgetItem(tr("Fir"), m_myListWidget);
connect( m_myListWidget, SIGNAL(itemClicked(QListWidgetItem *)), SLOT(itemClicked (QListWidgetItem *)));

}
void MyWidget::itemClicked(QListWidgetItem *item)
{

widget2 = new QPushButton("Text message");
widget3 = new QPushButton("Create Message");
QVBoxLayout *layout =new QVBoxLayout(this);
layout->addWidget(widget2);
layout->addWidget(widget3);
setLayout(layout);


}


MyWidget::~MyWidget()
{
delete m_myListWidget;
}
please any one can help me

wysota
27th April 2011, 09:17
You are not creating a new window when an item is clicked.

sabbu
2nd May 2011, 14:19
how to create new window please help me .i am beginner for symbian Qt

squidge
2nd May 2011, 15:36
Did you look at the examples?

Did you view the documentation for the list of classes?

sabbu
5th May 2011, 14:41
sir if you have possible then please send me small program how to go one window to another

ChrisW67
6th May 2011, 08:09
The code you have in MyWidget::itemClicked() does not, as Wysota pointed out, create a new window. You create a few widgets, put them in a layout and then set the layout of the current widget. Try putting that code into the constructor of a new class X derived from QWidget or QDialog. Then create a new instance of class X in MyWidget::itemClicked().