Results 1 to 2 of 2

Thread: Problem about using Designer to create menu,add action and slot?

  1. #1
    Join Date
    Jan 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problem about using Designer to create menu,add action and slot?

    hello,
    i am a newer of qt,and use designer,i found i can add some menu and sub menu of the mainwindow,can add a action to each menu item and a slot of the action,but i does not work,what is the matter?
      i use the vs 2008 with qt integration plugin.i created a new project of qt application. i add a menu item called 'SYSTEM,the objectname is :menuSYSTEM,then the plugin can create the code below:
      menuSYSTEM = new QMenu(menuBar);
    menuSYSTEM->setObjectName(QString::fromUtf8("menuSYSTEM"));
      
    after that ,i add a new action,and the Text property of the action is 'SYSTEM'。the code is:
      actionSysterm = new QAction(MainWindow);
    actionSysterm->setObjectName(QString::fromUtf8("actionSysterm" )) ;
    menuBar->addAction(menuSYSTEM->menuAction());
      
    now i add a slot which the sender is the action:
      QObject::connect(actionSystem,SIGNAL(trigg ered() ),MainWindow,SLOT(close());

    after i compile the code,i does not work。so i tried to modify the code of 'ui_Mainwindow.h'
    change menuBar->addAction(menuSYSTEM->menuAction());
    to
    menuBar->addAction(actionSystem);
    now it works.
    what is the matter?whether my procedure is right?
    i think that modify the ui_xxx.h is not a normal ,is that right?who can tell me how to do it?
    thanks.
      

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem about using Designer to create menu,add action and slot?

    Quote Originally Posted by sharkmouse View Post
    i am a newer of qt,and use designer,i found i can add some menu and sub menu of the mainwindow,can add a action to each menu item and a slot of the action,but i does not work,what is the matter?
    What does not work?

    It seems you menuSYSTEM is a menu and not an action. You probably added a submenu to your SYSTEM action (which caused it to be transformed into a menu) and then deleted it (but the menu was not converted back into an action automatically). Go back to Designer, delete the menu entry and create it again.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 5
    Last Post: 4th February 2010, 17:15
  2. action -> slot in Qt Designer
    By yuriry in forum Qt Tools
    Replies: 4
    Last Post: 6th October 2008, 19:17
  3. ToolBar Action With Menu
    By indifference in forum Qt Programming
    Replies: 4
    Last Post: 10th September 2007, 19:37
  4. Menu problem using Designer
    By JimBrown in forum Qt Tools
    Replies: 1
    Last Post: 19th February 2007, 21:47
  5. How to create custom slot in Qt Designer 4.1?
    By jamadagni in forum Qt Tools
    Replies: 31
    Last Post: 18th January 2006, 20:46

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.