Results 1 to 3 of 3

Thread: Passing Object to dll

  1. #1
    Join Date
    Mar 2006
    Location
    Vadodara, Gujarat, India
    Posts
    65
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question Passing Object to dll

    hi all,
    i've to make a dll to provide grid functionality (mostly excel type) like cut, copy,paste, redo,undo,add row, delete row.

    These functions are there in context menu as well as can use keyboard shortcuts like Ctrl+X for cut etc...

    i've inherited the QTableWidget class.

    i've implemented context menu also in a dll function and called the function in the main project.

    Now i am implementing the context menu functions.

    My problem is how to pass the object of table to the grid function on click of context menu.

    My project looks like below.



    Both upper and lower table are separate pointers (say temp1,temp2) of QGrid type.

    I am implementing the delete function.

    Following is the code snippet:

    Qt Code:
    1. // Constructors. creates the grid with x rows, y columns
    2.  
    3. QGrid::QGrid(int x, int y,QWidget *parent) : QTableWidget(x,y,parent)
    4. {
    5.  
    6. }
    7.  
    8. //Creates context menu in main program
    9.  
    10. void QGrid::setUpContextmenu()
    11. {
    12. addAction(deleterowAct);
    13. setContextMenuPolicy(Qt::ActionsContextMenu);
    14. }
    15.  
    16. void QGrid::createActions()
    17. {
    18. deleterowAct = new QAction(IDS_DELETEROW, this);
    19. deleterowAct->setStatusTip(tr("Delete a row"));
    20. connect(deleterowAct, SIGNAL(triggered()), this, SLOT(deleteTableRow()));
    21. deleterowAct->setEnabled(true);
    22. }
    23.  
    24. // delete row function
    25.  
    26. void QGrid::deleteTableRow()
    27. {
    28. QMessageBox::information(this,"hi","hello");
    29. this->removeRow(this->currentRow());
    30. }
    To copy to clipboard, switch view to plain text mode 



    The QMessageBox won't popup on cliking the delete and also the function is not working ... how can i pass the grid object (temp1/temp2). i used this pointer instead ... but it doesn't seem to work.

    also my other functions will require the pointers.

    what can be done ?
    Do what u r afraid to do, and the death of fear is sure.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Passing Object to dll

    You have to use signals and slots to connect your grids. You can then use the "sender()" method from within a slot to gain a pointer to the object which sent the signal.

  3. #3
    Join Date
    Mar 2006
    Location
    Vadodara, Gujarat, India
    Posts
    65
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Passing Object to dll

    i found the problem,
    in my class i hadn't wrote the macro Q_OBJECT, that was the problem.

    thanx wysota for ur time ... and sorrry to bug everyone with the post
    Do what u r afraid to do, and the death of fear is sure.

Similar Threads

  1. Passing an object from one form to the other.
    By cbarmpar in forum Qt Programming
    Replies: 10
    Last Post: 3rd September 2008, 15:12
  2. Replies: 4
    Last Post: 12th August 2008, 02:55
  3. passing an object
    By mickey in forum General Programming
    Replies: 3
    Last Post: 16th January 2008, 11:27
  4. Replies: 2
    Last Post: 17th May 2006, 22:01
  5. passing a QPainter object to widgets
    By vratojr in forum Qt Programming
    Replies: 9
    Last Post: 11th January 2006, 16:27

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.