// Create the menu structure
// *********************
// ** CREATE BASE MENU
// *********************
for(int i = 0; i < numberOfCategories; i++){
// *******************
// ** CREATE SUB MENU
// *******************
// ** FIND ALL DATA ENTRIES THAT ARE PART OF THE CURRENT CATEGORY
for(int j = 0; j < dataEntryCount; j++){
if(memcmp(dataEntryCategoryNameList[i], &dataEntryRawDataList[j][220], 30)==0){
// **********************
// ** ADD ACTION TO MENU
char temp[30];
memset(temp, 0x00, 30);
memcpy(temp, &dataEntryRawDataList[j][0], 30);
// OBTAIN RELEVANT COMMAND OPTIONS FOR THE CURRENT DATA ENTRY
int var1 = /*value obtained from file*/
int var2 = /*value obtained from file*/
int var3 = /*value obtained from file*/
int var4 = /*value obtained from file*/
int var5 = /*value obtained from file*/
//Function I want to call for the current data entry:
// myFunction(var1, var2, var3, var4, var5)
submenu->addAction(action);
// **********************
}
}
menu->addMenu(submenu);
}
// Create the menu structure
// *********************
// ** CREATE BASE MENU
QMenu *menu = new QMenu((QWidget*)ui->button);
// *********************
for(int i = 0; i < numberOfCategories; i++){
// *******************
// ** CREATE SUB MENU
QMenu *submenu = new QMenu(dataEntryCategoryNameList[i], (QWidget*)menu);
// *******************
// ** FIND ALL DATA ENTRIES THAT ARE PART OF THE CURRENT CATEGORY
for(int j = 0; j < dataEntryCount; j++){
if(memcmp(dataEntryCategoryNameList[i], &dataEntryRawDataList[j][220], 30)==0){
// **********************
// ** ADD ACTION TO MENU
char temp[30];
memset(temp, 0x00, 30);
memcpy(temp, &dataEntryRawDataList[j][0], 30);
// OBTAIN RELEVANT COMMAND OPTIONS FOR THE CURRENT DATA ENTRY
int var1 = /*value obtained from file*/
int var2 = /*value obtained from file*/
int var3 = /*value obtained from file*/
int var4 = /*value obtained from file*/
int var5 = /*value obtained from file*/
//Function I want to call for the current data entry:
// myFunction(var1, var2, var3, var4, var5)
QAction *action = new QAction(temp, (QObject*)submenu);
submenu->addAction(action);
// **********************
}
}
menu->addMenu(submenu);
}
menu->exec(QCursor::pos());
To copy to clipboard, switch view to plain text mode
Bookmarks