pospiech
25th August 2009, 21:09
I am trying to implement a popupmenu, but seam to fail somehow. (If this is considered as a newbie question move it there)
I placed the menu in a new class. I have mainly groups where a single action out of a group shall be selected. But I see neither a selection nor can I select anything. So what am I doing wrong?
#ifndef QPLOT3DMENU_H_
#define QPLOT3DMENU_H_
class QActionGroup;
class QAction;
#include <QtGui/QMenu>
class QPlot3DMenu : public QMenu
{
Q_OBJECT
public:
QPlot3DMenu(QWidget* parent = 0);
virtual ~QPlot3DMenu();
private:
QMenu *menuCoordinate_style;
QAction *actionBox;
QAction *actionFrame;
QAction *actionNone;
QActionGroup *alignmentGroupCoordinateStyle;
private:
void setupUi(QWidget* parent);
void retranslateUi(QWidget *widget);
};
#endif
#include "QPlot3DMenu.h"
#include <QtGui/QActionGroup>
#include <QtGui/QAction>
#include <QtGui/QMenu>
QPlot3DMenu::QPlot3DMenu( QWidget* parent /*= 0*/) : QMenu(parent)
{
setupUi(this);
}
QPlot3DMenu::~QPlot3DMenu()
{
}
void QPlot3DMenu::setupUi(QWidget* parent)
{
// --- Coordinate Style -------------------------------------------------------
menuCoordinate_style = new QMenu(this);
menuCoordinate_style->setObjectName(QString::fromUtf8("menuCoordinate_style"));
actionBox = new QAction(parent);
actionBox->setObjectName(QString::fromUtf8("actionBox"));
QIcon icon6;
icon6.addFile(QString::fromUtf8(":/box.png"), QSize(), QIcon::Normal, QIcon::Off);
actionBox->setIcon(icon6);
actionFrame = new QAction(parent);
actionFrame->setObjectName(QString::fromUtf8("actionFrame"));
QIcon icon7;
icon7.addFile(QString::fromUtf8(":/frame.png"), QSize(), QIcon::Normal, QIcon::Off);
actionFrame->setIcon(icon7);
actionNone = new QAction(parent);
actionNone->setObjectName(QString::fromUtf8("actionNone"));
QIcon icon8;
icon8.addFile(QString::fromUtf8(":/grid.png"), QSize(), QIcon::Normal, QIcon::Off);
actionNone->setIcon(icon8);
alignmentGroupCoordinateStyle = new QActionGroup(parent);
alignmentGroupCoordinateStyle->addAction(actionBox);
alignmentGroupCoordinateStyle->addAction(actionFrame);
alignmentGroupCoordinateStyle->addAction(actionNone);
actionBox->setChecked(true);
menuCoordinate_style->addAction(actionBox);
menuCoordinate_style->addAction(actionFrame);
menuCoordinate_style->addAction(actionNone);
parent->addAction(menuCoordinate_style->menuAction());
retranslateUi(parent);
QMetaObject::connectSlotsByName(parent);
} // setupUi
void QPlot3DMenu::retranslateUi(QWidget *widget)
{
actionBox->setText(QApplication::translate("MainWindow", "box", 0, QApplication::UnicodeUTF8));
actionFrame->setText(QApplication::translate("MainWindow", "frame", 0, QApplication::UnicodeUTF8));
actionNone->setText(QApplication::translate("MainWindow", "none", 0, QApplication::UnicodeUTF8));
menuCoordinate_style->setTitle(QApplication::translate("MainWindow", "coordinate style", 0, QApplication::UnicodeUTF8));
} // retranslateUi
The icons are not shown either. However I have never used resources and have no idea how to integrate them into Visual Studio correct.
Matthias
I placed the menu in a new class. I have mainly groups where a single action out of a group shall be selected. But I see neither a selection nor can I select anything. So what am I doing wrong?
#ifndef QPLOT3DMENU_H_
#define QPLOT3DMENU_H_
class QActionGroup;
class QAction;
#include <QtGui/QMenu>
class QPlot3DMenu : public QMenu
{
Q_OBJECT
public:
QPlot3DMenu(QWidget* parent = 0);
virtual ~QPlot3DMenu();
private:
QMenu *menuCoordinate_style;
QAction *actionBox;
QAction *actionFrame;
QAction *actionNone;
QActionGroup *alignmentGroupCoordinateStyle;
private:
void setupUi(QWidget* parent);
void retranslateUi(QWidget *widget);
};
#endif
#include "QPlot3DMenu.h"
#include <QtGui/QActionGroup>
#include <QtGui/QAction>
#include <QtGui/QMenu>
QPlot3DMenu::QPlot3DMenu( QWidget* parent /*= 0*/) : QMenu(parent)
{
setupUi(this);
}
QPlot3DMenu::~QPlot3DMenu()
{
}
void QPlot3DMenu::setupUi(QWidget* parent)
{
// --- Coordinate Style -------------------------------------------------------
menuCoordinate_style = new QMenu(this);
menuCoordinate_style->setObjectName(QString::fromUtf8("menuCoordinate_style"));
actionBox = new QAction(parent);
actionBox->setObjectName(QString::fromUtf8("actionBox"));
QIcon icon6;
icon6.addFile(QString::fromUtf8(":/box.png"), QSize(), QIcon::Normal, QIcon::Off);
actionBox->setIcon(icon6);
actionFrame = new QAction(parent);
actionFrame->setObjectName(QString::fromUtf8("actionFrame"));
QIcon icon7;
icon7.addFile(QString::fromUtf8(":/frame.png"), QSize(), QIcon::Normal, QIcon::Off);
actionFrame->setIcon(icon7);
actionNone = new QAction(parent);
actionNone->setObjectName(QString::fromUtf8("actionNone"));
QIcon icon8;
icon8.addFile(QString::fromUtf8(":/grid.png"), QSize(), QIcon::Normal, QIcon::Off);
actionNone->setIcon(icon8);
alignmentGroupCoordinateStyle = new QActionGroup(parent);
alignmentGroupCoordinateStyle->addAction(actionBox);
alignmentGroupCoordinateStyle->addAction(actionFrame);
alignmentGroupCoordinateStyle->addAction(actionNone);
actionBox->setChecked(true);
menuCoordinate_style->addAction(actionBox);
menuCoordinate_style->addAction(actionFrame);
menuCoordinate_style->addAction(actionNone);
parent->addAction(menuCoordinate_style->menuAction());
retranslateUi(parent);
QMetaObject::connectSlotsByName(parent);
} // setupUi
void QPlot3DMenu::retranslateUi(QWidget *widget)
{
actionBox->setText(QApplication::translate("MainWindow", "box", 0, QApplication::UnicodeUTF8));
actionFrame->setText(QApplication::translate("MainWindow", "frame", 0, QApplication::UnicodeUTF8));
actionNone->setText(QApplication::translate("MainWindow", "none", 0, QApplication::UnicodeUTF8));
menuCoordinate_style->setTitle(QApplication::translate("MainWindow", "coordinate style", 0, QApplication::UnicodeUTF8));
} // retranslateUi
The icons are not shown either. However I have never used resources and have no idea how to integrate them into Visual Studio correct.
Matthias