Results 1 to 5 of 5

Thread: Problem with QT programming

  1. #1
    Join Date
    Feb 2011
    Posts
    29
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows

    Default Problem with QT programming

    Hi all,

    I need help very urgently.
    I am trying to change push button geometry when i press tab key.

    I have done it with mouse move event. so when mouse arrow is on push button it changes shape.

    now i want that when i select push button using tab key it changes its shape.
    I don't know how to do it.

    Please help me in that matter. how can i do this. please send me code to perform this action.

    Thanks in advance.

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with QT programming

    Have you tried installing an event listener?

  3. #3
    Join Date
    Feb 2011
    Posts
    29
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QT programming

    No i have try Key event.

    this is in my1.cpp

    void my1::keyPressEvent(QKeyEvent *event)
    {
    if (event->key() == Qt::Key_Tab)
    {
    pushButton->setGeometry(QRect(100, 110, 150, 101));
    }
    else
    {
    pushButton->setGeometry(QRect(100, 110, 140, 50));
    }
    }


    in my1.h file i write

    class my1 : public QWidget,private Ui_my1
    {
    Q_OBJECT

    public:
    explicit my1(QWidget *parent = 0, Qt::WindowFlags f = 0 );
    ~my1();

    Protected:
    void keyPressEvent(QKeyEvent * event);

    };

    but when i press tab key it does not change push button geometry. Please help me how to do this function.
    Please if possible provide me code to implement this functionality.

    thanks in advance... waiting for reply.........

  4. #4
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    131
    Thanks
    11
    Thanked 16 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with QT programming

    from C++ GUI Programming with Qt 4 page 164:
    The Tab and Backtab (Shift+Tab) keys are special cases. They are handled by
    QWidget::event() before it calls keyPressEvent(), with the semantic of passing
    the focus to the next or previous widget in the focus chain.
    Update: Also the online doc for QWidget::event() documents that.

  5. #5
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with QT programming

    keyPressEvent is insufficient (for the reason shown above). Install an event listener, as I've stated above.

Similar Threads

  1. A problem about Model/view programming
    By calmspeaker in forum Qt Programming
    Replies: 2
    Last Post: 13th June 2009, 04:00
  2. a design problem in multithread programming
    By ryen in forum Qt Programming
    Replies: 4
    Last Post: 4th April 2009, 13:46
  3. Very strange socket programming problem
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2008, 12:05
  4. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  5. model View programming problem
    By mismael85 in forum Qt Programming
    Replies: 3
    Last Post: 2nd April 2008, 21:44

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.