Results 1 to 7 of 7

Thread: promoted widgets using QT designer is not calling its constructor

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2009
    Posts
    60
    Thanks
    3
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default promoted widgets using QT designer is not calling its constructor

    Dear All,

    I made a subclass of QLineEdit class and implemented its constructor and keyPressEvent event handler,then I promoted one of the instances of QLineEdit to subclass with QT Designer by right clicking and selecting the promote option. I am able to call keyPressEvent() method in my application. however the constructor of this subclass is never called.

    header file.
    Qt Code:
    1. class printlineEdit : public QLineEdit
    2. {
    3. //Q_OBJECT
    4.  
    5. public:
    6. //signals:
    7. // void escapePress();
    8. public:
    9.  
    10. printlineEdit(QWidget *parent = 0);
    11. void keyPressEvent( QKeyEvent *event );
    12. unsigned int ValuePut,val;
    13.  
    14. };
    To copy to clipboard, switch view to plain text mode 


    its corresponding c++ file.

    Qt Code:
    1. printlineEdit::printlineEdit(QWidget *parent):QLineEdit(parent)
    2. {
    3. ValuePut=0;
    4. //selectionStart ();
    5. //setCursorPosition(0);
    6. printf("Inside printline constr\n");
    7. }
    8.  
    9. void printlineEdit::keyPressEvent(QKeyEvent *event)
    10. {
    11. bool flag=0;
    12. QString ch("");
    13.  
    14. switch(event->key())
    15. {
    16. case Qt::Key_Left:
    17. break;
    18. case Qt::Key_Right:
    19.  
    20. break;
    21. case Qt::Key_Up:
    22. break;
    23. case Qt::Key_Down:
    24.  
    25. break;
    26. case Qt::Key_Return:
    27. flag=1;
    28. printf("Enter Pressed\n");
    29. break;
    30. }
    31. }
    32. }
    To copy to clipboard, switch view to plain text mode 

    Now for the above code the constructor printlineEdit(QWidget *parent) is never called.

    Kindly tell me how to implement a constructor in these scenario.

    Ratheendran
    Last edited by wysota; 3rd April 2011 at 08:37. Reason: changed [quote] to [code]

Similar Threads

  1. Promoted widgets in Qt Designer
    By martinb0820 in forum Qt Tools
    Replies: 1
    Last Post: 9th June 2010, 15:07
  2. Replies: 0
    Last Post: 24th October 2009, 07:38
  3. Call Constructor within Designer
    By NoRulez in forum Qt Programming
    Replies: 22
    Last Post: 24th June 2009, 08:27
  4. Replies: 4
    Last Post: 12th August 2008, 01:55
  5. Promoted widgets and layout boxes
    By notsonerdysunny in forum Qt Tools
    Replies: 3
    Last Post: 2nd May 2007, 14:15

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.