c++ - OOP menu system -


i trying make menu system (with submenus) using qgraphics qt4.8. composite pattern sounds solution got stuck.

this uml diagram: http://i.stack.imgur.com/jgwpq.png

the objects structured tree.

      +-------------+       |root         |+---------------------+       +-------------+|                     |          +           |                     |          |           |                     |          |           |                     |          |           v                     v +-------<++         +----------+    +----------------+ |leaf1    |    +---+|menunode1 |    | menunode2      |+--------+ +---------+    |    +----------+    +----------------+         |                |            +                  +               |                |            |                  |               |                v            v                  v               v        +---------+ +-----------+     +-------------+       +-------------+        |leaf2    | |leaf3      |     | menunode4   |       |leaf5        |        +---------+ +-----------+     +-------+-----+       +-------------+                                      +       |                                      |       |                                      |       v                          +---------+ |  +------------+                          |         <-+  |            |                          +---------+    +------------+ 

the first problem qt paints hole structure, want show children of current node. tried solve making abstractmenuitems not visibile and

void menunode::paint( qpainter *painter, ....) {     if( this->parentwidget() == abstractmenuitem::currentposition) { //show direct children          for(int = 0; i<3; i++) {//show 3 elements @ time               child->at(i)->setvisibile(true);               child->at(i)->setfocus( == 1 );           }        } else { //paint child        painter->drawtext("child menunode");     } } 

i think ideea isn't oo. tips making better?

first off, presume don't want menu items qt widgets.

next, encapsulate graphic objects can use qgraphicsscene programmable "field" , qgraphicsitem menu items program. takes more questions/answers specify more detailed implementation, though. believe these classes available in qt 4.8 well. advantages of opengl-based programming well.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -