QCalenderWidget double click event not working or am i doing wrong?



  • class Calendar : public QCalendarWidget
    {
    Q_OBJECT
    public:
    Calendar(QWidget* parent = 0);
    signals:
    void showToDoWindow();
    private:
    void mouseDoubleClickEvent(QMouseEvent*);

    };
    void Calendar::mouseDoubleClickEvent(QMouseEvent *e)
    {
    if ( e->button() == Qt::LeftButton )
    emit showToDoWindow();
    }

    connect(ui->calendarWidget,SIGNAL(showToDoWindow()),this,SLOT(showToDoWindow())); // my connection in mainwindow
    

    void MainWindow::showToDoWindow()
    {// this slot function doesnt execute when the user doubleclick a date in the calendar
    qDebug() << "s";
    } // this slot

    i have a QCalendarWidget in my ui form, im trying to do something when the user double clicks a date in calendar but doesnt work


  • Qt Champions 2016

    Hi
    The signal Activated also triggers for db clicks.
    so

    connect(ui->calendarWidget, QCalendarWidget::activated, this , MainWindow::CalendarDBClick);
    
    and the slot function
    public slots:
      void CalendarDBClick(const QDate& Date) {
       setWindowTitle(Date.toString("dd.MM.yyyy"));
      }
    

    No need to subclass, just hook up signal.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.