#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QWidget>
#include <QCalendarWidget>
#include <QVBoxLayout>
#include <iostream>
{
Q_OBJECT
public:
public slots:
void calClicked
( const QDate & ) ;
} ;
void MyWidget
::calClicked ( const QDate & theDate
) { std::cout << theDate.toString( "ddd MMMM d yyyy" ).toStdString() << std::endl ;
}
{
quit->setGeometry ( 62, 40, 75, 30 ) ;
quit
->setFont
( QFont( "Times",
18,
QFont::Bold ) ) ;
connect ( quit, SIGNAL( clicked() ), qApp, SLOT(quit()) ) ;
connect ( dateEdit, SIGNAL( clicked(const QDate&) ), this, SLOT(calClicked(const QDate&)) ) ;
layout->addWidget(dateEdit);
layout->addWidget(quit);
setLayout(layout);
}
int main(int argc, char* argv[] )
{
MyWidget widget ;
widget.show() ;
return app.exec() ;
}
#include "main.moc"
#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QWidget>
#include <QCalendarWidget>
#include <QVBoxLayout>
#include <iostream>
class MyWidget : public QWidget
{
Q_OBJECT
public:
MyWidget(QWidget *parent = 0) ;
public slots:
void calClicked ( const QDate & ) ;
} ;
void MyWidget::calClicked ( const QDate & theDate )
{ std::cout << theDate.toString( "ddd MMMM d yyyy" ).toStdString() << std::endl ;
}
MyWidget::MyWidget ( QWidget *parent ) : QWidget ( parent )
{
QPushButton *quit = new QPushButton ( tr ( "Quit" ), this ) ;
quit->setGeometry ( 62, 40, 75, 30 ) ;
quit->setFont ( QFont( "Times", 18, QFont::Bold ) ) ;
connect ( quit, SIGNAL( clicked() ), qApp, SLOT(quit()) ) ;
QCalendarWidget *dateEdit = new QCalendarWidget () ;
connect ( dateEdit, SIGNAL( clicked(const QDate&) ), this, SLOT(calClicked(const QDate&)) ) ;
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(dateEdit);
layout->addWidget(quit);
setLayout(layout);
}
int main(int argc, char* argv[] )
{
QApplication app(argc, argv ) ;
MyWidget widget ;
widget.show() ;
return app.exec() ;
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks