Results 1 to 6 of 6

Thread: Menu item action problem

  1. #1
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Menu item action problem

    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:

    Qt Code:
    1. <addaction name="actionQSL_Data_Label"/>
    To copy to clipboard, switch view to plain text mode 

    But it doesn't compile with this:
    Qt Code:
    1. connect(ui->actionQSL_Data_Label, SIGNAL(triggered(bool)),
    2. this, SLOT(printQslData()));
    To copy to clipboard, switch view to plain text mode 
    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Menu item action problem

    Did you add that line manually?
    If so, clean the project, run qmake and build the project.
    Does this help?

  3. The following user says thank you to tbscope for this useful post:

    waynew (13th December 2010)

  4. #3
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Menu item action problem

    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.

  5. #4
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Menu item action problem

    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.

  6. #5
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Menu item action problem

    Can you create a compilable example please?
    I would like to test it.

  7. #6
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Menu item action problem

    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.

Similar Threads

  1. Display action as menu item without icon?
    By bmueller63 in forum Qt Programming
    Replies: 0
    Last Post: 21st October 2010, 20:51
  2. Replies: 5
    Last Post: 4th February 2010, 17:15
  3. Replies: 1
    Last Post: 22nd January 2010, 11:22
  4. Action-Menu-Button
    By hgedek in forum Newbie
    Replies: 1
    Last Post: 1st October 2007, 16:41
  5. ToolBar Action With Menu
    By indifference in forum Qt Programming
    Replies: 4
    Last Post: 10th September 2007, 19:37

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.