PDA

View Full Version : Model Items do not updated



rimie23
8th June 2012, 17:09
Hi,

in mainwindow


public slots:
void itemAded ( QStandardItem * );




MainWindow::MainWindow()
{

mQOgreWidget = new QOgreWidget(this);

setCentralWidget(mQOgreWidget);

createModel();
createDockWidget();


}




void MainWindow::createDockWidget()
{
listView = new QListView(dockWidgetContents_8);
listView->setObjectName(QString::fromUtf8("listView"));
listView->setGeometry(QRect(0, 0, 281, 290));
listView->setModel( model );
connect( model, SIGNAL( itemChanged( QStandardItem * )),
this, SLOT( itemChanged( QStandardItem * )));
connect( model, SIGNAL( itemAded( QStandardItem * )),
mQOgreWidget, SLOT( itemAded( QStandardItem * )));
connect( mQOgreWidget, SIGNAL( itemAded( QStandardItem * )), this, SLOT( itemAded( QStandardItem * ) ));

in my class QOgrerenderWidget .h
i defined my sognal itemAded like that


public slots:
void add_object();
signals :
void itemAded( QStandardItem * );

in QOgrerenderWidget .cpp


void QOgreRenderWindow::mousePressEvent(QMouseEvent* evt)
{

if(evt->button() == Qt::LeftButton)
{
add_object();
}
}
void QOgreRenderWindow::add_object(double offsetX ,double offsetY)
{
/////////////////////////////////////////////
code to add object
it work very good
///////////////////////////////////////////////////////
QStandardItem *item=new QStandardItem(QString ("Marker %0").arg(nb));
emit itemAded(item);

and in Qogrewidget i make like that

QOgreRenderWindow * orw0 = new QOgreRenderWindow(QString("View2"),mSceneMgr,mRoot,nb_cam,wi0,hi0, mNode);


i can add the object with any problem
but the item do not added

edit :
problem is resolved when i add many view

wysota
8th June 2012, 22:26
Are you sure this problem was resolved when you added more views? The code you posted here doesn't make much sense. It seems you are confusing signals with slots.