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. Adding notes to QCalendarWidget
Forum Updated to NodeBB v4.3 + New Features

Adding notes to QCalendarWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 231 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.
  • S Offline
    S Offline
    symHeisenberg
    wrote on last edited by aha_1980
    #1

    I have managed to highlight dates on QCalendar, but I want to add notes to those such that when those dates are clicked the user can see the notes. How can I do it?

    QDate dateToHighlight(2024, 7, 23); 
    
    QTextCharFormat highlightFormat;
    
    highlightFormat.setBackground(Qt::yellow);
    
    calendar->setDateTextFormat(dateToHighlight, highlightFormat);
    
    Pl45m4P jsulmJ 2 Replies Last reply
    0
    • S symHeisenberg

      I have managed to highlight dates on QCalendar, but I want to add notes to those such that when those dates are clicked the user can see the notes. How can I do it?

      QDate dateToHighlight(2024, 7, 23); 
      
      QTextCharFormat highlightFormat;
      
      highlightFormat.setBackground(Qt::yellow);
      
      calendar->setDateTextFormat(dateToHighlight, highlightFormat);
      
      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @symHeisenberg

      Maybe add a layout with labels below or next to it?!
      Or maybe even use a proper model / view.

      Edit:
      The title says QCalendarWidget, the post QCalendar?!
      QCalendarWidget is a (kinda) closed widget in itself (like QTableWidget vs a QTableView approach for table modelling)... you could embed it in your own widget and add your layout, as I mention above.
      Another way is writing your own calendar notes widget from scratch using QCalendar and a model/view for managing the notes and other data.
      Unless there is already something like that around I haven't seen yet.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      0
      • S symHeisenberg

        I have managed to highlight dates on QCalendar, but I want to add notes to those such that when those dates are clicked the user can see the notes. How can I do it?

        QDate dateToHighlight(2024, 7, 23); 
        
        QTextCharFormat highlightFormat;
        
        highlightFormat.setBackground(Qt::yellow);
        
        calendar->setDateTextFormat(dateToHighlight, highlightFormat);
        
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @symHeisenberg You could show a widget when https://doc.qt.io/qt-6/qcalendarwidget.html#clicked is emitted where you show the notes for the date which was clicked.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        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