PDA

View Full Version : Menu item action problem



waynew
13th December 2010, 02:05
Ok, this is dumb senior moment time. I have an application with many menu and submenu items where the actions work fine. So I add a new action as a submenu item and it shows up fine in the Designer and in the ui code:



<addaction name="actionQSL_Data_Label"/>


But it doesn't compile with this:


connect(ui->actionQSL_Data_Label, SIGNAL(triggered(bool)),
this, SLOT(printQslData()));

The error message is: class Ui::MainWindow has no member named 'actionQSL_Data_Label'

And if I comment out the connect line, the application compiles and runs but the submenu item for the action doesn't show up in the menu.

I'm sure this is some simple mistake I'm making but I can't see it.
Adding a menu or submenu item and using the action created always worked before. But I haven't created any except this one since upgrading to Creator 2.0.1 and Qt 4.7.0

Any ideas?

tbscope
13th December 2010, 05:27
Did you add that line manually?
If so, clean the project, run qmake and build the project.
Does this help?

waynew
13th December 2010, 14:04
Thanks tbscope - no, that was Designer generated code using Creator 2.0.1 and Qt 4.7.0
If I do the same thing using 1.3.1 and 4.6.2 it works fine.

waynew
14th December 2010, 00:50
Now I have confirmed that the same project/code fails to recognize the Designer created action using 2.0.1/4.7.0
but works just fine with 1.3.1/4.6.2 Must be a bug. I'm sticking with the old version for now.

tbscope
14th December 2010, 05:21
Can you create a compilable example please?
I would like to test it.

waynew
15th December 2010, 00:42
Ok tbscope - here is what I did. Created a new simple gui project using 2.0.1/4.7.0 - everything worked fine.

Then I did another test, which mirrored what happened with my large project. I created a project called MenuTest using 1.3.1/4.6.2 and made a menu as File/Print/QSL Address Label That worked ok. Then I opened that project using 2.0.1/4.7.0 and added another submenu under print. QSL Data Label, just like I did in my large project.
Same error, the last added action is not recognized even though you can see it in the ui file that Designer created. If you comment out the connect statement for the added action, the project compiles, but the added action does not show up on the menu.

Even zipped, the project is a little too large to attach here, so I have put in on the Downloads page of my website: k4elo.net as MenuTest.

Is there something special you have to do if you create a project using an older Qt 4 version then open it in the latest version?
If so , I missed it.