Results 1 to 6 of 6

Thread: How to start a function in parent with QItemDelegate

  1. #1
    Join Date
    Jan 2007
    Posts
    201
    Thanks
    22
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default How to start a function in parent with QItemDelegate

    Hello all

    We have QItemDelegate like this.
    Qt Code:
    1. if(index.column() == 12)
    2. {
    3. QLineEdit *editor = new QLineEdit(parent);
    4. connect(editor, SIGNAL(returnPressed()), parent, SLOT(x_x()));
    5. return editor;
    6. }
    To copy to clipboard, switch view to plain text mode 

    I would like to start x_x function from the parent, but I was not able to do it? Do you have any idea?

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to start a function in parent with QItemDelegate

    pass pointer to needed object trought ctor of delegate and then use it in connect.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Jan 2007
    Posts
    201
    Thanks
    22
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to start a function in parent with QItemDelegate

    How can I do it? any example?

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to start a function in parent with QItemDelegate

    Qt Code:
    1. void MyDelegate::setCustomHandler(QWidget *handler)
    2. {
    3. m_handler = handler;
    4. }
    5. ....
    6. if(index.column() == 12) {
    7. QLineEdit *editor = new QLineEdit(parent);
    8. connect(editor, SIGNAL(returnPressed()), m_handler, SLOT(x_x()));
    9. return editor;
    10. }
    11. ....
    12. MyDelegate *delegate = new MyDelegate();
    13. delegate->setCustomHandler(this);
    14. ....
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Jan 2007
    Posts
    201
    Thanks
    22
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to start a function in parent with QItemDelegate

    I get a error like this.

    m_handler' undeclared (first use
    this function)

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to start a function in parent with QItemDelegate

    you have to declare it like a class member, i.e.
    Qt Code:
    1. class MyDeleaget: public QItemDelegate
    2. {
    3. .....
    4. private:
    5. QWidget *m_handler;
    6. };
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  3. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

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.