Results 1 to 7 of 7

Thread: What's wrong with my actions???

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 127 Times in 121 Posts

    Default Re: What's wrong with my actions???

    I have a node (the typename doesn't matter here) inheriting from QObject. It has a void contextMenuEvent(const QPoint& p) called from the view (first block of code) and the setupMenu() is also a member of this class. The puzzling thing is that I tried substituting signal/slots with QMetaObject::invokeMethod but it did not give any result either...

    EDIT :
    Yeah!!! I've solved it! My fix is (very) dirty but inheritance-aware as I needed and AFAIK the Trolls have no reason changing the syntax of the meta-object system before a while...
    I suppose the problem comes from the fact that my nodes are created in a separate thread (to avoid GUI freeze) which gets destroyed afterward (thus no event loop is running). So I added a "QHash<QAction*, const char*> slot_table;" member which is filled in the setupMenu() method with appropriate action-method name pairs. Then, after menu execution I use the following code :
    Qt Code:
    1. QAction *a = m.exec(p);
    2.  
    3. if ( a && slot_table.contains(a) )
    4. {
    5. int idx = metaObject()->indexOfSlot(slot_table[a]);
    6. qt_metacall(QMetaObject::InvokeMetaMethod, idx, 0);
    7. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by fullmetalcoder; 4th March 2007 at 10:30.
    Current Qt projects : QCodeEdit, RotiDeCode

Similar Threads

  1. Ideas about how to implement Undo and Redo actions?
    By pir in forum General Discussion
    Replies: 3
    Last Post: 21st July 2006, 09:27
  2. QListWidget...what's wrong
    By nupul in forum Newbie
    Replies: 16
    Last Post: 4th April 2006, 12:17
  3. Replies: 1
    Last Post: 18th March 2006, 16:37
  4. Help please - what am I doing wrong?
    By Jimmy2775 in forum Qt Programming
    Replies: 6
    Last Post: 6th March 2006, 22:06
  5. Actions and what to do with them?
    By krsmichael in forum Qt Tools
    Replies: 2
    Last Post: 20th January 2006, 22:08

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
  •  
Qt is a trademark of The Qt Company.