hi all,

i've made a dll to provide some table functions ( excel like ) to my main project. It works fine with linkage and all. The code to make context menu and calling it is also in the dll part, in the constructor.

My problem is, in my table in the main project, i get context menu at all places, except at the headers. Like in excel on right click on the headers select all rows/columns and giv a context menu there also. My context menu is not coming on the header.

what can be the problem.
below is my dll code:

Qt Code:
  1. //QGrid.cpp
  2.  
  3. #include <QtGui>
  4. #include "QGrid.h"
  5. #include <QMessageBox>
  6.  
  7.  
  8. QGrid::QGrid(int r, int c,QWidget *parent) : QTableWidget(r,c,parent)
  9. {
  10. createActions();
  11. setUpContextMenu();
  12. }
  13.  
  14.  
  15. QGrid::QGrid(QWidget *parent) : QTableWidget(parent)
  16. {
  17. createActions();
  18. setUpContextMenu();
  19. }
  20.  
  21. void QGrid::setUpContextMenu()
  22. {
  23. addAction(copyAct);
  24. addAction(pasteAct);
  25. ...
  26. setContextMenuPolicy(Qt::ActionsContextMenu);
  27. }
  28.  
  29. void QGrid::createActions()
  30. {
  31. copyAct = new QAction(QIcon(":/images/copy.png"), "&Copy", this);
  32. copyAct->setShortcut(tr("Ctrl+C"));
  33. copyAct->setStatusTip(tr("Copy the current selection's contents to the "
  34. "clipboard"));
  35. connect(copyAct, SIGNAL(triggered()), this, SLOT(copy()));
  36.  
  37. pasteAct = new QAction(QIcon(":/images/paste.png"), "&Paste", this);
  38. pasteAct->setShortcut(tr("Ctrl+V"));
  39. pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
  40. "selection"));
  41. connect(pasteAct, SIGNAL(triggered()), this, SLOT(paste()));
  42.  
  43. ....
  44. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. //QGrid.h
  2.  
  3. #ifndef QGRID_H
  4. #define QGRID_H
  5. #include <QtCore/qglobal.h>
  6. #include <QtGui/QDialog>
  7. #include <QAction>
  8. #include <QTableWidget>
  9.  
  10. #ifdef BUILD_QGRID
  11. # ifdef Q_CC_MSVC
  12. # define QGRID_EXPORT Q_DECL_EXPORT
  13. # else
  14. # define QGRID_EXPORT Q_DECL_IMPORT
  15. # endif
  16. #else
  17. # define QGRID_EXPORT
  18. #endif
  19.  
  20. class QGRID_EXPORT QGrid : public QTableWidget
  21. {
  22. Q_OBJECT
  23. public:
  24. QGrid(int c,int r,QWidget *parent = 0);
  25. QGrid(QWidget *parent = 0);
  26. QClipboard *clip;
  27. QTableWidget *table;
  28.  
  29. private:
  30. QAction *copyAct;
  31. QAction *pasteAct;
  32. ....
  33. public slots:
  34.  
  35. void copy();
  36. void paste();
  37. ....
  38. public:
  39. void setUpContextMenu();
  40. void createActions();
  41. };
  42. #endif
To copy to clipboard, switch view to plain text mode 

please help ....