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) :
QWidget(parent)
{
m_size = size;
theLabel = new QLabel;
QFont font("DIN-Light", 24, QFont::Bold);
theLabel->setFrameStyle(QFrame::Box | QFrame::Raised);
theLabel->setFont(font);
QDate date = QDate::currentDate();QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(showdate())); timer->start(1000); showdate();
}
void DateTextDisplay::showdate()
{
QDate date = QDate::currentDate();
theLabel->setText(date.longDayName(date.day()));
}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.
Tony
-
Maybe try create label with parent?
@
theLabel = new QLabel( this );
@ -
Yep. That got it.
Thanks :-)