[Qt-interest] sketcher program

Mihail Naydenov mlists at ymail.com
Fri May 13 18:52:41 CEST 2011


Your question(s) are too broad and much more design then Qt related.

As an opinion a static class for current colors, pens and others sounds 
reasonable to me.

MihailNaydenov



----- Original Message ----
> From: phil prentice <philp.cheer at talktalk.net>
> To: qt-interest at qt.nokia.com
> Sent: Fri, May 13, 2011 6:51:04 PM
> Subject: [Qt-interest] sketcher program
> 
> Hi
>   I Really dig Qt, but have difficulty deciding the best way of doing  things 
> sometimes.
>   I have a design question regarding a Qt a play  program that I am writing.  
> Its very basic, but I was wondering if  anyone would be able to point me in 
> the right direction with regard to the  correct way of accessing member 
> variables in the mainwindow.
> 
>   I  have a main window (with menus etc) which has a central widget which is a 

> QMdiArea.
>   The QMdiArea has a list of QMdiSubwindows.  
>   Each subwindow has a graphicsView  (set by  setWidget())
>   
>   I also have a list of scenes (QGraphicsScene,  one for each open document).  

> This list at the moment I keep in the  QMainwindow object.  Each subwindow's 
> (graphicsview) is associated with  one scene.  Each scene, obviously can have 
> more then one view  (different zoom factors or what ever).
> 
>   At the moment I have a  derived graphicsview and I have overwridden the 
> mousePressEvent() member  function to start the creation of elements (say a 
> line).  I intend to  grab the cursor until all the required points have been 
> input to define the  element, and then create it in the appropriate scene
> 
>   To start with  rightly or wrongly I am hoping to create an element item (say 

> a  QGraphicsLineItem) using multiple calls to the mousePressEvent()  function.
> 
>   However to do this I need access to the current pen  colour which is handled 

> by the menu options in the mainwindow object.   Its copied into a member 
> variable inside the derived Qmainwindow  object.
> 
>   How should I access it....should I use qApp and search for  the mainwindow 
> widget in its widget list(Seems a bit naff)  or should I  make the mainwindow 
> object global(I could bodge it that way, but surely  there is a better way). I 

> could create a static function in the mainwindow  that returns the current pen 

> (the trouble there is I might need to access  loads of other member 
> variables)?  What would be considered the best  method to do this?
> 
> Your thoughts would be very welcome
> Thanks for your  help
> _______________________________________________
> Qt-interest mailing  list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
> 



More information about the Qt-interest-old mailing list