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. QCalendarWidget doesn't resize properly
QtWS25 Last Chance

QCalendarWidget doesn't resize properly

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 2.7k Views
  • 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.
  • Ioseph12I Offline
    Ioseph12I Offline
    Ioseph12
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • Ioseph12I Offline
      Ioseph12I Offline
      Ioseph12
      wrote on last edited by
      #4

      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);
      
      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #2

        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.

        Ioseph12I 1 Reply Last reply
        4
        • mrjjM mrjj

          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.

          Ioseph12I Offline
          Ioseph12I Offline
          Ioseph12
          wrote on last edited by
          #3

          @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

          1 Reply Last reply
          0
          • Ioseph12I Offline
            Ioseph12I Offline
            Ioseph12
            wrote on last edited by
            #4

            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);
            
            1 Reply Last reply
            0
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #5

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

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              1 Reply Last reply
              3

              • Login

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