Widget won't display

  • I'm writing a clock app that consists of three widgets - an analog clock (using QSvgRenderer), a digital clock (QLCDNumber), and a date display using QLabel. My main window has a main widget with a central layout that, in turn, contains a QHBoxLayout for the analog clock and a QVBoxLayout for the digital clock and date widgets. The analog and digital clock widgets behave normally but the date widget won't display at all. Code for my date widget:

    @DateTextDisplay::DateTextDisplay(QWidget *parent, QSize size) :
    m_size = size;
    theLabel = new QLabel;
    QFont font("DIN-Light", 24, QFont::Bold);
    theLabel->setFrameStyle(QFrame::Box | QFrame::Raised);
    QDate date = QDate::currentDate();

    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(showdate()));


    void DateTextDisplay::showdate()
    QDate date = QDate::currentDate();

    QSize DateTextDisplay::sizeHint() const
    return m_size;

    Oddly, I can get the date label to display if I invoke QLabel from my MainWindow code (which creates the above widget). I'm a n00b at Qt so won't be surprised if I'm doing something stupid.

    Any help appreciated.


  • Maybe try create label with parent?
    theLabel = new QLabel( this );

  • Yep. That got it.

    Thanks :-)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.