Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Widget won't display
Qt 6.11 is out! See what's new in the release blog

Widget won't display

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tonygrim
    wrote on last edited by
    #1

    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

    Dona nobis pacem

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Hostel
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tonygrim
        wrote on last edited by
        #3

        Yep. That got it.

        Thanks :-)

        Dona nobis pacem

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved