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. [SOLVED] QCalendarWidget.setDateEditEnabled(bool) does nothing.
Qt 6.11 is out! See what's new in the release blog

[SOLVED] QCalendarWidget.setDateEditEnabled(bool) does nothing.

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 2.9k 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.
  • P Offline
    P Offline
    pwnstar23
    wrote on last edited by
    #1

    I'm trying to set a QCalendarWidget so it cannot be modified. I think that is what this method is for but it doesn't work.

    Other widgets have a setReadOnly(bool) method but this one doesn't for what ever reason.

    Am I doing it wrong?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TFabbri
      wrote on last edited by
      #2

      Hi,
      do you try this?
      I've created the project with QtCreator, and with these instructions an user can't modify the calendar.

      @#include "mainwindow.h"
      #include "ui_mainwindow.h"

      MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
      {
      ui->setupUi(this);
      ui->calendarWidget->setEnabled(false);

      }

      MainWindow::~MainWindow()
      {
      delete ui;
      }@

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pwnstar23
        wrote on last edited by
        #3

        I looked into this but there is no such function on the calendar widget, when the intellisense thing pops up. Looking at the docs also seems to confirm this. I am using 4.8.1

        Also it seems the function I'm trying to use, doesn't do what the name sounds like it should, I'm new to QT so I'm not sure what it's talking about, from the docs....

        dateEditEnabled : bool
        This property holds whether the date edit popup is enabled.
        If this property is enabled, pressing a non-modifier key will cause a date edit to popup if the calendar widget has focus, allowing the user to specify a date in the form specified by the current locale.
        By default, this property is enabled.
        The date edit is simpler in appearance than QDateEdit, but allows the user to navigate between fields using the left and right cursor keys, increment and decrement individual fields using the up and down cursor keys, and enter values directly using the number keys.
        This property was introduced in Qt 4.3.

        1 Reply Last reply
        0
        • U Offline
          U Offline
          uranusjr
          wrote on last edited by
          #4

          What happens when dateEditEnabled is set to true is that you can input a date with your keyboard to change the date displayed on the calendar.

          But you need to specify a bit what you mean with "modify the calendar widget" because I don't get whether this is what you want. The described behavior works for me.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            pwnstar23
            wrote on last edited by
            #5

            I'm looking for the functionality that the calendar doesn't change the date when the user clicks on it. In effect is is readonly.

            The other widget's in my dialog have .setReadOnly(bool) which does for those widgets exactly what I need.

            I need this functionality because i have a dialog with two of these calendars one displays the old date which should never change, and the other is the one the user modifies.

            1 Reply Last reply
            0
            • U Offline
              U Offline
              uranusjr
              wrote on last edited by
              #6

              Then TFabbri was right, you need to setEnabled(false) to the calendar widget. Something like

              @
              QCalendarWidget *cal = new QCalendarWidget();
              cal->setEnabled(false);
              cal->setDateEditEnabled(false);
              @

              dateEditEnabled controls whether the calendar widget can be edited with keyboard, while enabled controls whether the widget accepts mouse events.

              Notice that enabled is a property inherited from QWidget; that's why you couldn't find it in the doc page of QCalendarWidget.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                TFabbri
                wrote on last edited by
                #7

                If you solve the problem, change the topic with a heading [SOLVED].

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  pwnstar23
                  wrote on last edited by
                  #8

                  Yep solved.

                  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