PDA

View Full Version : [SOLVED] Whats wrong with my QAction, and Edit Shortcuts dialog



Xagen
18th March 2006, 14:06
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:


void MainWindow::loadActions()
{
QSettings settings;
settings.beginGroup("/Action");
QList<QAction *> actions = qFindChildren<QAction *>(this);

for (int i = 0; i < actions.size(); ++i)
{
QAction *action = static_cast<QAction*>(actions.at( i ));
QString accelText = settings.value(action->text()).toString();
if (!accelText.isNull())
action->setShortcut(QKeySequence(accelText));
}

settings.endGroup();
}

void MainWindow::saveActions()
{
QSettings settings;
settings.beginGroup("/Action");

QList<QAction *> actions = qFindChildren<QAction *>(this);

for (int i = 0; i < actions.size(); ++i)
{
QAction *action = static_cast<QAction*>(actions.at( i ));

QString accelText = QString(action->shortcut());
settings.setValue(action->text(), accelText);

}

settings.endGroup();
}

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!

Xagen
18th March 2006, 16:37
I used QActionGroup insead of qFindChildren;

:p