Results 1 to 2 of 2

Thread: [SOLVED] Whats wrong with my QAction, and Edit Shortcuts dialog

  1. #1
    Join Date
    Jan 2006
    Location
    Minsk, Brest, Belarus
    Posts
    54
    Thanks
    3
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Unhappy [SOLVED] Whats wrong with my QAction, and Edit Shortcuts dialog

    Hello!

    I have a question.
    I'm writing small application now and when I was creating "Edit Shortcuts" dialog I've noticed that something was changed in QT.
    In qt3 items of menus were not of type QAction, but in qt4 they are. Why?

    Here is the code:

    Qt Code:
    1. void MainWindow::loadActions()
    2. {
    3. QSettings settings;
    4. settings.beginGroup("/Action");
    5. QList<QAction *> actions = qFindChildren<QAction *>(this);
    6.  
    7. for (int i = 0; i < actions.size(); ++i)
    8. {
    9. QAction *action = static_cast<QAction*>(actions.at( i ));
    10. QString accelText = settings.value(action->text()).toString();
    11. if (!accelText.isNull())
    12. action->setShortcut(QKeySequence(accelText));
    13. }
    14.  
    15. settings.endGroup();
    16. }
    17.  
    18. void MainWindow::saveActions()
    19. {
    20. QSettings settings;
    21. settings.beginGroup("/Action");
    22.  
    23. QList<QAction *> actions = qFindChildren<QAction *>(this);
    24.  
    25. for (int i = 0; i < actions.size(); ++i)
    26. {
    27. QAction *action = static_cast<QAction*>(actions.at( i ));
    28.  
    29. QString accelText = QString(action->shortcut());
    30. settings.setValue(action->text(), accelText);
    31.  
    32. }
    33.  
    34. settings.endGroup();
    35. }
    To copy to clipboard, switch view to plain text mode 
    It works good but in the "Edit Shortcuts" dialog in the table there are also items like these:

    - File Actions
    - &File
    - & Help
    This is the title of the menus...

    How to disable them?

    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Minsk, Brest, Belarus
    Posts
    54
    Thanks
    3
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default [solved]

    I used QActionGroup insead of qFindChildren;


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.