QCalendarWidget doesn't resize properly



  • Hi everyone,

    I've been trying to put a QCalendarWidget inside a custom widget that i'm designing. The problem is that it does not fit the widget width so, even it resizes the navigation bar right, the table appears cropped

    https://postimg.org/image/5xt53f817/

    Is there any way to adjust the table width to fix this ?

    Thanks


  • Qt Champions 2016

    Hi
    You are using an layout?

    Just tested. It seems that each numbers box has a fixed size and it won't reduce the font used nor the
    interspace between the number boxes.
    So there is minimum size it will scale to before some of the days row till be clipped.



  • @mrjj

    No, only a frame as a container. I can resize the table font size but, as you well said it seems as the box sizes are fixed



  • Finally I found a good method to rescale the children table. It's some crazy thing but it works

    calendar = new QCalendarWidget(frame);
    	calendar->setObjectName(QStringLiteral("calendar"));
    	calendar->setGeometry(QRect(1, 40, 281, 183));
    	calendar->setLocale(QLocale::English);
    	calendar->setFirstDayOfWeek(Qt::DayOfWeek::Monday);
    	calendar->showToday();
    	QTableView* aux = calendar->findChild<QTableView*>();
    	aux->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::Fixed);
    	aux->horizontalHeader()->setDefaultSectionSize(40);
    


  • For the record, the correct way, as mentioned by @mrjj above is to add a layout


Log in to reply
 

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