Results 1 to 2 of 2

Thread: A qwidget passed to a function does nothing....

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    56
    Thanked 1 Time in 1 Post

    Default A qwidget passed to a function does nothing....

    This is a piece of code for my 'QTUTIL' class
    .h
    Qt Code:
    1. ....
    2. public
    3. void time_start_crono(QWidget *indicador);
    4. void time_update();
    5. private:
    6. QWidget *time_widget_indicator;
    7. ....
    To copy to clipboard, switch view to plain text mode 
    .cpp

    Qt Code:
    1. void W_qtutil::time_start_crono(QWidget *indicador) {
    2. time_widget_indicator=indicador;
    3. ....}
    4. void W_qtutil::time_update() {
    5. ((QLabel) W_qtutil::time_widget_indicator).setText("hello");
    To copy to clipboard, switch view to plain text mode 
    }

    I have at my mainwindow.cpp :
    Qt Code:
    1. W_qtutil *w_qt=new W_qtutil();
    2. w_qt->time_start_crono(ui->label_tiempo);
    3. ....
    4. w_qt->time_update();
    To copy to clipboard, switch view to plain text mode 

    I create the w_qt using forward style (to avoid circular dependencies)
    But My label are not updated ....
    Any idea ? Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    5
    Thanked 86 Times in 81 Posts

    Default Re: A qwidget passed to a function does nothing....

    Some questions:

    1) time_update is not a slot;

    2) To cast QObject use QObject::qobject_cast.

    3 ) If you are sure that time_widget_indicator is a QLabel, why you don't declare it as QLabel?
    A camel can go 14 days without drink,
    I can't!!!

Similar Threads

  1. Replies: 4
    Last Post: 20th January 2011, 02:03
  2. Replies: 0
    Last Post: 24th October 2010, 20:09
  3. Replies: 1
    Last Post: 25th September 2010, 09:20
  4. connect between function of two differents QWidget
    By shenakan in forum Qt Programming
    Replies: 3
    Last Post: 9th September 2010, 19:32
  5. Displaying QWidget from a function.
    By raghvendramisra in forum Qt Programming
    Replies: 2
    Last Post: 23rd January 2008, 05:02

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.