[Qgis-developer] Help needed in creating Third Level Submenu

Bishwarup Banerjee bishwarup.banerjee at gmail.com
Wed Aug 5 02:14:25 EDT 2009


Dear German,

Thank you very much for clearing my understanding. Now  I am able to do What
I was looking for, with slight modifications in the code.

Thank you very much once again.
Bye and take care

2009/8/5 Germán Carrillo <carrillo.german at gmail.com>

> Bishwarup, you can use addActions in your self.DM object because it is an
> instance of QMenu, which inherits from QWidget. While your self.Div1 is an
> instance of QAction which doesn't inherits from QWidget, so self.Div1 can't
> access to addActions method.
>
> Take a look at this: http://doc.qtsoftware.com/4.5/classes.html
>
> Germán
>
> El 4 de agosto de 2009 00:14, Bishwarup Banerjee <
> bishwarup.banerjee at gmail.com> escribió:
>
> Hi German,
>>
>> Thank you very much for your reply. I will try to incorporate the way you
>> suggested. But, I thing I was wondering is that if "addActions" does not
>> inherits from QAction, then how is that when I go to only second level of
>> submenu option, instead of thrird level, it works fine. The problem arises
>> only when we go to the third level.
>>
>> With warm Regards,
>> Bishwarup
>>
>> 2009/8/3 Germán Carrillo <carrillo.german at gmail.com>
>>
>> Hi Bishwarup, the addActions method is in QWidget class, and QAction don't
>>> inherited from that. So addActions don't exist for QAction. Maybe you can
>>> use QtDesigner to create the menu level you want and then generate the .py
>>> with pyuirc4, this way you can see how to create it.
>>>
>>> Why you don't use the last QGis version?
>>>
>>> Germán
>>>
>>> 2009/8/3 Bishwarup Banerjee <bishwarup.banerjee at gmail.com>
>>>
>>>> Dear All,
>>>>
>>>> I am trying to create THIRD LEVEL MENU  through the following code. Like
>>>> I have a menu Called "Boundaries", inside that I have sub menu called
>>>> "Division", inside that I have "Division_name", inside "Division Name" we
>>>> have a separate sub menu called "Division Range", on clicking on the sub
>>>> menu "Division range" some action is done, like opening the range boundary
>>>> shape file. I am able to open the Shape file portion, but I am getting error
>>>> in the Bold Line marked as "AttributeError: addActions"
>>>>
>>>>         self.menu = QMenu()
>>>>         self.menu.setTitle( "Boundaries" )
>>>>
>>>>         self.DM = QMenu( "Division" )
>>>>         self.Div1 = QAction( QIcon( ":/icons/find.png" ), "Division
>>>> Name",self.iface.getMainWindow() )
>>>>         self.DM.addActions( [ self.Div1])
>>>>         self.menu.addMenu( self.DM )
>>>>         menuBar = self.iface.getMainWindow().menuBar()
>>>>         menuBar.addMenu(self.menu)
>>>>
>>>>         self.Div_Range = QAction( QIcon( ":/icons/find.png" ), "Division
>>>> Range",self.iface.getMainWindow() )
>>>>         *self.Div1.addActions( [ self.Div_Range])*
>>>>         self.menu.addMenu( self.Div_Range )
>>>>         menuBar = self.iface.getMainWindow().menuBar()
>>>>         menuBar.addMenu(self.menu)
>>>>
>>>>         QObject.connect( self.Div_Range, SIGNAL("triggered()"),
>>>> self.Div1_Clicked )
>>>>
>>>> It will be of immense help, if anybody can point the error in the code,
>>>> or is it like THIRD LEVEL SUBMENU is not supported in QGIS?
>>>>
>>>> I am using QGIS 0.11, Python 2.5 and QT.
>>>>
>>>> I am posting the same in the QGIS Developer forum
>>>>
>>>> Thanking you in advance,
>>>>
>>>> With Warm Regards
>>>>
>>>>
>>>> _______________________________________________
>>>> Qgis-developer mailing list
>>>> Qgis-developer at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>>>>
>>>>
>>> --
>>> -----------
>>>   |\__
>>> (:>__)(
>>>   |/
>>>
>>> Soluciones Geoinformáticas Libres
>>> http://geotux.tuxfamily.org/
>>>
>>>
> --
> -----------
>   |\__
> (:>__)(
>   |/
>
> Soluciones Geoinformáticas Libres
> http://geotux.tuxfamily.org/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20090805/92870501/attachment.html


More information about the Qgis-developer mailing list