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. insert QCalendarWidget into QTableView Column cells
Forum Updated to NodeBB v4.3 + New Features

insert QCalendarWidget into QTableView Column cells

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 740 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.
  • KaguroK Offline
    KaguroK Offline
    Kaguro
    wrote on last edited by
    #1

    Hi Guys!
    I have a QTableView and i would like to achive that when i click into a date cell pop up a QCalendarWidget from it and i can select the date (like spinbox delegate example).
    How can i achive this?
    Thanks your help!

    JonBJ 1 Reply Last reply
    0
    • KaguroK Kaguro

      @JonB I didnt say about QComboBox but yeah mousewheel is do nothing in QComboBox as well. But in the QCalendarWidget is do, but do the qtableview also, the calendar is open in vain.
      If i disable the QtableView with table->setDisabled(true) then disable the calendar as well. Or there is a different way for it?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #6

      @Kaguro said in insert QCalendarWidget into QTableView Column cells:

      If i disable the QtableView with table->setDisabled(true) then disable the calendar as well.

      When/where do you do this? I was thinking it would be OK at the end of createEditor(), or even perhaps in, say, the QCalendarWidget::showEvent(), but maybe not. It was just a suggestion.

      I now see bool QStyledItemDelegate::eventFilter(QObject *editor, QEvent *event) [override virtual protected]. Are you maybe supposed to override that and make it return true for the events you say are presently handled by the QTableView but you would like handled by your QCalendarWidget?

      KaguroK 1 Reply Last reply
      2
      • KaguroK Kaguro

        Hi Guys!
        I have a QTableView and i would like to achive that when i click into a date cell pop up a QCalendarWidget from it and i can select the date (like spinbox delegate example).
        How can i achive this?
        Thanks your help!

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #2

        @Kaguro
        So adapt the QSpinBox delegate example to use QCalendarWidget. QStyledItemDelegate::createEditor() is where you create you desired editing QWidget.

        KaguroK 1 Reply Last reply
        0
        • JonBJ JonB

          @Kaguro
          So adapt the QSpinBox delegate example to use QCalendarWidget. QStyledItemDelegate::createEditor() is where you create you desired editing QWidget.

          KaguroK Offline
          KaguroK Offline
          Kaguro
          wrote on last edited by
          #3

          @JonB Sorry for late!
          Thanks the advice its working partly.
          When pop up the calendar i cant select the date with mouse click or enter (nothing happen). If i clcik somewhere else the calendar widget close perfectly and write the selected date into the cell, its good.
          When i use arrow or mousewheel to select a date then activate the qtableview events, so select another qtableview cell or scrolling the tableview with mousewheel.
          So how can i ignore qtableview events when popup the calendar? And how can i select the date into the cell with doublemouseclick or enter?
          Thanks your help! :)

          JonBJ 1 Reply Last reply
          0
          • KaguroK Kaguro

            @JonB Sorry for late!
            Thanks the advice its working partly.
            When pop up the calendar i cant select the date with mouse click or enter (nothing happen). If i clcik somewhere else the calendar widget close perfectly and write the selected date into the cell, its good.
            When i use arrow or mousewheel to select a date then activate the qtableview events, so select another qtableview cell or scrolling the tableview with mousewheel.
            So how can i ignore qtableview events when popup the calendar? And how can i select the date into the cell with doublemouseclick or enter?
            Thanks your help! :)

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #4

            @Kaguro
            Only a guess. Not sure why/whether, say, mousewheel works for a QComboBox but not for a QCalendarWidget. Maybe one way would be to disable the QTableView while the QCalendarWidget is being edited, if that makes the events go to the latter instead? Or maybe do this with an eventFilter()?

            KaguroK 1 Reply Last reply
            0
            • JonBJ JonB

              @Kaguro
              Only a guess. Not sure why/whether, say, mousewheel works for a QComboBox but not for a QCalendarWidget. Maybe one way would be to disable the QTableView while the QCalendarWidget is being edited, if that makes the events go to the latter instead? Or maybe do this with an eventFilter()?

              KaguroK Offline
              KaguroK Offline
              Kaguro
              wrote on last edited by
              #5

              @JonB I didnt say about QComboBox but yeah mousewheel is do nothing in QComboBox as well. But in the QCalendarWidget is do, but do the qtableview also, the calendar is open in vain.
              If i disable the QtableView with table->setDisabled(true) then disable the calendar as well. Or there is a different way for it?

              JonBJ 1 Reply Last reply
              0
              • KaguroK Kaguro

                @JonB I didnt say about QComboBox but yeah mousewheel is do nothing in QComboBox as well. But in the QCalendarWidget is do, but do the qtableview also, the calendar is open in vain.
                If i disable the QtableView with table->setDisabled(true) then disable the calendar as well. Or there is a different way for it?

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #6

                @Kaguro said in insert QCalendarWidget into QTableView Column cells:

                If i disable the QtableView with table->setDisabled(true) then disable the calendar as well.

                When/where do you do this? I was thinking it would be OK at the end of createEditor(), or even perhaps in, say, the QCalendarWidget::showEvent(), but maybe not. It was just a suggestion.

                I now see bool QStyledItemDelegate::eventFilter(QObject *editor, QEvent *event) [override virtual protected]. Are you maybe supposed to override that and make it return true for the events you say are presently handled by the QTableView but you would like handled by your QCalendarWidget?

                KaguroK 1 Reply Last reply
                2
                • JonBJ JonB

                  @Kaguro said in insert QCalendarWidget into QTableView Column cells:

                  If i disable the QtableView with table->setDisabled(true) then disable the calendar as well.

                  When/where do you do this? I was thinking it would be OK at the end of createEditor(), or even perhaps in, say, the QCalendarWidget::showEvent(), but maybe not. It was just a suggestion.

                  I now see bool QStyledItemDelegate::eventFilter(QObject *editor, QEvent *event) [override virtual protected]. Are you maybe supposed to override that and make it return true for the events you say are presently handled by the QTableView but you would like handled by your QCalendarWidget?

                  KaguroK Offline
                  KaguroK Offline
                  Kaguro
                  wrote on last edited by
                  #7

                  @JonB Thanks i can handle every event in the bool QStyledItemDelegate::eventFilter(QObject *editor, QEvent *event) . Works enter key press ... calendar close and the valu set into the cells! Thanks again it works perfectly! :D

                  1 Reply Last reply
                  1

                  • Login

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