Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-2226

QCalendarWidget : change font for month and year buttons.

    XMLWordPrintable

Details

    Description

      There should be an easy way of changing the font of the Month and Year ToolButtons in the QCalandarWidget.

      At the moment the only way to do this seems to be to use findChildren, and this creates a solution that relies on internal design of the widget and may change with any release of Qt.

      #include <QtGui>
      int main(int argc, char *argv[])
      {
      QApplication app(argc, argv);
      QCalendarWidget qcalendarwidget;

      QFont font ("Helvetica [Cronyx]",20);

      QTextCharFormat format;

      qcalendarwidget.setHeaderTextFormat(format);
      QToolButton *button;
      QList<QToolButton *> allTButtons = qcalendarwidget.findChildren<QToolButton *>();

      if (allTButtons.count() != 0)

      { qDebug() << allTButtons.count() << " buttons found!"; allTButtons[2]->setFont(font); }

      else

      { qDebug() << "button was null"; }

      qcalendarwidget.show();

      return app.exec();
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            smd Jan Arve
            dettman Dean Dettman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes