Results 1 to 20 of 21

Thread: should i use listview ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2012
    Posts
    101
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: should i use listview ?

    ok
    that's the code of add_object
    Qt Code:
    1. void OgreWidget::add_object(const Ogre::Vector3 &pos)
    2. {
    3.  
    4. Ogre::String name1 = "entity " + Ogre::StringConverter::toString(Ogre::Root::getSingletonPtr()->getTimer()->getMicroseconds());
    5. mEntity = ogreSceneManager->createEntity(name1, Ogre::SceneManager:: PT_CUBE);
    6.  
    7. Ogre::MaterialPtr material1111 = Ogre::MaterialManager::getSingleton().create("green", "General");
    8.  
    9.  
    10. material1111->getTechnique( 0 )->getPass( 0 )->setAmbient(1, 1, 0);
    11. mEntity->setMaterial(material1111);
    12. Ogre::String name = "Node " + Ogre::StringConverter::toString(Ogre::Root::getSingletonPtr()->getTimer()->getMicroseconds()); // Provides a unique timestamp - the time since the application was started in microseconds.
    13. mNode = ogreSceneManager->getRootSceneNode()->
    14. createChildSceneNode(name, pos);
    15. mNode->attachObject(mEntity);
    16. count++;
    17.  
    18. QStandardItem *item=new QStandardItem(QString ("Cube %0").arg(count));
    19.  
    20. //model->setItem(count,item);
    21. model->appendRow(item);
    22. QListView *listview;
    23. listview->update();
    24.  
    25. ogreRenderWindow->update();
    26. this->update();
    27.  
    28. }
    To copy to clipboard, switch view to plain text mode 
    i just do that

  2. #2
    Join Date
    Nov 2010
    Posts
    82
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 9 Times in 9 Posts

    Default Re: should i use listview ?

    so "model" must be a member variable of OgreWidget
    and it must be set somewhere right ?

  3. #3
    Join Date
    Apr 2012
    Posts
    101
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: should i use listview ?

    beh
    i define model in mainwinows
    Qt Code:
    1. lass MainWindow : public QMainWindow
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6.  
    7. listView = new QListView(dockWidgetContents_8);
    8. listView->setObjectName(QString::fromUtf8("listView"));
    9. listView->setGeometry(QRect(0, 0, 281, 290));
    10.  
    11. listView->setModel(model);
    To copy to clipboard, switch view to plain text mode 
    i think i bad understand how i use the "model" no? (i modifate qt assistant exemple )

  4. #4
    Join Date
    Nov 2010
    Posts
    82
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 9 Times in 9 Posts

    Default Re: should i use listview ?

    so you must have a crash when doing model->appendRow(item); in OgreWidget right ?
    if it s true it s just that you need that ogreWidget ask for the model pointer to Mainwindow, else how do you want OgreWidget to know what model is ?

  5. #5
    Join Date
    Apr 2012
    Posts
    101
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: should i use listview ?

    you need that ogreWidget ask for the model pointer to Mainwindow, else how do you want OgreWidget to know what model is ?
    how i do that (when i see the exemple in qt assistant it make just like that maybe because he is in the same class?)
    so how i said to ogre widget to applicate the model in mainwindows , but at first is my definition of the model in mainwinows true ?

  6. #6
    Join Date
    Nov 2010
    Posts
    82
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 9 Times in 9 Posts

    Default Re: should i use listview ?

    just create a set_model function(const QStandardItemModel *model) function in ogrewiget that will save the pointer value to a member variable
    then call it after you create the model in mainwindow (i suppose you create the ogrewidget in the same function as the model)

  7. #7
    Join Date
    Apr 2012
    Posts
    101
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: should i use listview ?

    i suppose you create the ogrewidget in the same function as the model)
    create model like that ?
    Qt Code:
    1. model->appendRow(item);
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Apr 2012
    Posts
    101
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: should i use listview ?

    Ok , i define my model like that
    in ogrewidget.cpp
    Qt Code:
    1. QStandardItemModel* OgreWidget::add_object(/*Ogre::Real*/double offsetX ,/*Ogre::Real*/double offsetY)
    2. {
    3. .................................................
    4. model= new QStandardItemModel();
    5. int i=1;
    6. for(itr = result.begin() ;itr != result.end();++itr)
    7. {
    8. if(itr->movable)
    9. {
    10.  
    11. MarkerNode->_setDerivedPosition(mouseRay.getPoint(itr->distance));
    12. MarkerNode->setScale(0.1f, 0.1f, 0.1f);
    13. QStandardItem *item=new QStandardItem(QString ("Marker %0").arg(i));
    14. model->appendRow(item);
    15. i++;
    16.  
    17. }
    18. }
    19. return model;
    20. }
    To copy to clipboard, switch view to plain text mode 
    and in my_interface.cpp
    Qt Code:
    1. list_O = new QToolButton(page_13);
    2. list_O->setGeometry(QRect(30, 210, 101, 31));
    3. list_O->setText(QApplication::translate("MainWindow", "Object Liste", 0, QApplication::UnicodeUTF8));
    4. listView =new QListView(list_O);
    To copy to clipboard, switch view to plain text mode 
    but it still do not make to me the list

  9. #9
    Join Date
    Apr 2012
    Posts
    101
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: should i use listview ?

    i want just to know what i forget to do

Similar Threads

  1. qml listview
    By Le_B in forum Qt Quick
    Replies: 1
    Last Post: 25th May 2011, 13:01
  2. subsection in listview
    By huluyige in forum Qt Quick
    Replies: 1
    Last Post: 25th February 2011, 10:26
  3. how do you reload a listView?
    By implor in forum Newbie
    Replies: 5
    Last Post: 16th May 2010, 22:21
  4. ListView problems
    By waitingforzion in forum Newbie
    Replies: 2
    Last Post: 26th December 2009, 00:24
  5. listview
    By addu in forum Qt Programming
    Replies: 2
    Last Post: 11th May 2009, 12:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.