本文整理汇总了C++中QCalendarWidget类的典型用法代码示例。如果您正苦于以下问题:C++ QCalendarWidget类的具体用法?C++ QCalendarWidget怎么用?C++ QCalendarWidget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QCalendarWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sender
void QgsAttributeEditor::selectDate()
{
QPushButton *pb = qobject_cast<QPushButton *>( sender() );
if ( !pb )
return;
QWidget *hbox = qobject_cast<QWidget *>( pb->parent() );
if ( !hbox )
return;
QLineEdit *le = hbox->findChild<QLineEdit *>();
if ( !le )
return;
QDialog *dlg = new QDialog();
dlg->setWindowTitle( tr( "Select a date" ) );
QVBoxLayout *vl = new QVBoxLayout( dlg );
QCalendarWidget *cw = new QCalendarWidget( dlg );
cw->setSelectedDate( QDate::fromString( le->text(), Qt::ISODate ) );
vl->addWidget( cw );
QDialogButtonBox *buttonBox = new QDialogButtonBox( dlg );
buttonBox->addButton( QDialogButtonBox::Ok );
buttonBox->addButton( QDialogButtonBox::Cancel );
vl->addWidget( buttonBox );
connect( buttonBox, SIGNAL( accepted() ), dlg, SLOT( accept() ) );
connect( buttonBox, SIGNAL( rejected() ), dlg, SLOT( reject() ) );
if ( dlg->exec() == QDialog::Accepted )
{
le->setText( cw->selectedDate().toString( Qt::ISODate ) );
}
}
示例2: QDialog
void LxQtClock::activated(ActivationReason reason)
{
if (reason != ILxQtPanelPlugin::Trigger)
return;
if (!mCalendarDialog)
{
mCalendarDialog = new QDialog(mContent);
//mCalendarDialog->setAttribute(Qt::WA_DeleteOnClose, true);
mCalendarDialog->setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog | Qt::X11BypassWindowManagerHint);
mCalendarDialog->setLayout(new QHBoxLayout(mCalendarDialog));
mCalendarDialog->layout()->setMargin(1);
QCalendarWidget* cal = new QCalendarWidget(mCalendarDialog);
cal->setFirstDayOfWeek(mFirstDayOfWeek);
mCalendarDialog->layout()->addWidget(cal);
mCalendarDialog->adjustSize();
QRect pos = calculatePopupWindowPos(mCalendarDialog->size());
mCalendarDialog->move(pos.topLeft());
mCalendarDialog->show();
}
else
{
delete mCalendarDialog;
mCalendarDialog = 0;
}
}
示例3: QCalendarWidget
QGraphicsItem *WidgetDemo::item() {
QCalendarWidget *date = new QCalendarWidget(0);
date->setWindowOpacity(0.2);
date->resize(300, 200);
date->move(20, 20);
return new PlexyDesk::WidgetItem(QRectF(0, 0, 340, 240), date);
}
示例4: setupCalenderWidget
void MultiDelegate::setupCalenderWidget( QDateTimeEdit* editor) const
{
editor->setCalendarPopup(true);
QCalendarWidget* calendar = editor->calendarWidget();
if (calendar) {
calendar->setFirstDayOfWeek(Qt::Monday);
calendar->setVerticalHeaderFormat( QCalendarWidget::ISOWeekNumbers);
}
}
示例5: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QCalendarWidget *label = new QCalendarWidget();
label->setObjectName(QString::fromUtf8("label"));
label->setGeometry(QRect(100, 100, 200, 100));
// label->setText("Hello World");
label->show();
return app.exec();
}
示例6: QCalendarWidget
void CmdTestRedirectPaint::activated(int iMsg)
{
QCalendarWidget* cal = new QCalendarWidget();
QLabel* label = new QLabel();
QPainter::setRedirected(cal,label);
cal->setWindowTitle(QString::fromAscii("QCalendarWidget"));
cal->show();
label->show();
label->setWindowTitle(QString::fromAscii("QLabel"));
}
示例7: switch
void LXQtWorldClock::activated(ActivationReason reason)
{
switch (reason)
{
case ILXQtPanelPlugin::Trigger:
case ILXQtPanelPlugin::MiddleClick:
break;
default:
return;
}
if (!mPopup)
{
mPopup = new LXQtWorldClockPopup(mContent);
connect(mPopup, SIGNAL(deactivated()), SLOT(deletePopup()));
if (reason == ILXQtPanelPlugin::Trigger)
{
mPopup->setObjectName(QLatin1String("WorldClockCalendar"));
mPopup->layout()->setContentsMargins(0, 0, 0, 0);
QCalendarWidget *calendarWidget = new QCalendarWidget(mPopup);
mPopup->layout()->addWidget(calendarWidget);
QString timeZoneName = mActiveTimeZone;
if (timeZoneName == QLatin1String("local"))
timeZoneName = QString::fromLatin1(QTimeZone::systemTimeZoneId());
QTimeZone timeZone(timeZoneName.toLatin1());
calendarWidget->setFirstDayOfWeek(QLocale(QLocale::AnyLanguage, timeZone.country()).firstDayOfWeek());
calendarWidget->setSelectedDate(QDateTime::currentDateTime().toTimeZone(timeZone).date());
}
else
{
mPopup->setObjectName(QLatin1String("WorldClockPopup"));
mPopupContent = new QLabel(mPopup);
mPopup->layout()->addWidget(mPopupContent);
mPopupContent->setAlignment(mContent->alignment());
updatePopupContent();
}
mPopup->adjustSize();
mPopup->setGeometry(calculatePopupWindowPos(mPopup->size()));
willShowWindow(mPopup);
mPopup->show();
}
else
{
deletePopup();
}
}
示例8: setTextFormat
void tst_QCalendarWidget::setTextFormat()
{
QCalendarWidget calendar;
QTextCharFormat format;
format.setFontItalic(true);
format.setForeground(Qt::green);
const QDate date(1984, 10, 20);
calendar.setDateTextFormat(date, format);
QCOMPARE(calendar.dateTextFormat(date), format);
}
示例9: QCalendarWidget
QDate QtopiaInputDialog::getDate(QWidget *parent, const QString &title, const QString &label, const QDate &date,
const QDate &minDate, const QDate &maxDate, bool *ok)
{
#ifdef CALENDAR_FOR_DATE
QCalendarWidget *cal = new QCalendarWidget();
cal->setSelectedDate(date);
cal->setMinimumDate(minDate);
cal->setMaximumDate(maxDate);
cal->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);
QTextCharFormat headerFormat = cal->headerTextFormat();
headerFormat.setBackground(QApplication::palette().window());
headerFormat.setForeground(QApplication::palette().windowText());
cal->setHeaderTextFormat(headerFormat);
QWidget *navBar = cal->findChild<QWidget*>("qt_calendar_navigationbar");
if (navBar)
navBar->setBackgroundRole(QPalette::Window);
QtopiaInputDialog dlg(parent, title, label, cal);
bool accepted = (QtopiaApplication::execDialog(&dlg) == QDialog::Accepted);
if (ok)
*ok = accepted;
return cal->selectedDate();
#else
QDateEdit *de = new QDateEdit(date);
de->setMinimumDate(minDate);
de->setMaximumDate(maxDate);
QtopiaInputDialog dlg(parent, title, label, de);
bool accepted = (QtopiaApplication::execDialog(&dlg) == QDialog::Accepted);
if (ok)
*ok = accepted;
return de->date();
#endif
}
示例10: QDialog
void BlDateSearch::s_searchFecha()
{
BL_FUNC_DEBUG
QDialog *diag = new QDialog ( 0 );
diag->setModal ( true );
QCalendarWidget *calend = new QCalendarWidget ( diag );
/// Se pone el 1er dia del calendario a lunes.
calend->setFirstDayOfWeek ( Qt::Monday );
/// Evitar fechas demasiado antiguas
calend->setMinimumDate( QDate ( 1900, 1, 1 ) );
/// Si el campo estaba vacío, seleccionar una fecha imposible, pero mostrar el mes actual
if ( m_textoFecha->text().isEmpty() ) {
calend->setSelectedDate ( calend->minimumDate() );
calend->setCurrentPage ( QDate::currentDate().year(), QDate::currentDate().month() );
}
/// Si ya hay una fecha en el campo, abrir el calendario con ese día seleccionado inicialmente
else {
calend->setSelectedDate ( blNormalizeDate ( m_textoFecha->text() ) );
}
connect ( calend, SIGNAL ( activated ( const QDate & ) ), diag, SLOT ( accept() ) );
/// Creamos un layout donde estara el contenido de la ventana y la ajustamos al QDialog
/// para que sea redimensionable y aparezca el titulo de la ventana.
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget ( calend );
layout->setMargin ( 0 );
layout->setSpacing ( 0 );
diag->setLayout ( layout );
diag->setWindowTitle ( _ ( "Seleccione fecha" ) );
diag->exec();
/// Si la fecha es imposible, significa que el usuario no ha seleccionado una fecha
/// y su campo debe quedarse como estaba: vacío
if ( calend->selectedDate() != QDate ( 1900, 1, 1 ) ) {
m_textoFecha->setText ( calend->selectedDate().toString ( "dd/MM/yyyy" ) );
}
/// Liberamos la memoria
delete layout;
delete calend;
delete diag;
emit ( valueChanged ( m_textoFecha->text() ) );
emit ( editingFinished () );
}
示例11: setWeekdayFormat
void tst_QCalendarWidget::setWeekdayFormat()
{
QCalendarWidget calendar;
QTextCharFormat format;
format.setFontItalic(true);
format.setForeground(Qt::green);
calendar.setWeekdayTextFormat(Qt::Wednesday, format);
// check the format of the a given month
for (int i = 1; i <= 31; ++i) {
const QDate date(1984, 10, i);
const Qt::DayOfWeek dayOfWeek = static_cast<Qt::DayOfWeek>(date.dayOfWeek());
if (dayOfWeek == Qt::Wednesday)
QCOMPARE(calendar.weekdayTextFormat(dayOfWeek), format);
else
QVERIFY(calendar.weekdayTextFormat(dayOfWeek) != format);
}
}
示例12: if
void Overview::UpdateCalendarDay(QDateEdit *dateedit, QDate date)
{
QCalendarWidget *calendar = dateedit->calendarWidget();
QTextCharFormat bold;
QTextCharFormat cpapcol;
QTextCharFormat normal;
QTextCharFormat oxiday;
bold.setFontWeight(QFont::Bold);
cpapcol.setForeground(QBrush(Qt::blue, Qt::SolidPattern));
cpapcol.setFontWeight(QFont::Bold);
oxiday.setForeground(QBrush(Qt::red, Qt::SolidPattern));
oxiday.setFontWeight(QFont::Bold);
bool hascpap = p_profile->FindDay(date, MT_CPAP) != nullptr;
bool hasoxi = p_profile->FindDay(date, MT_OXIMETER) != nullptr;
//bool hasjournal=p_profile->GetDay(date,MT_JOURNAL)!=nullptr;
if (hascpap) {
if (hasoxi) {
calendar->setDateTextFormat(date, oxiday);
} else {
calendar->setDateTextFormat(date, cpapcol);
}
} else if (p_profile->GetDay(date)) {
calendar->setDateTextFormat(date, bold);
} else {
calendar->setDateTextFormat(date, normal);
}
calendar->setHorizontalHeaderFormat(QCalendarWidget::ShortDayNames);
}
示例13: buttonClickCheck
void tst_QCalendarWidget::buttonClickCheck()
{
QCalendarWidget object;
QSize size = object.sizeHint();
object.setGeometry(0,0,size.width(), size.height());
object.show();
object.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&object));
QDate selectedDate(2005, 1, 1);
//click on the month buttons
int month = object.monthShown();
QToolButton *button = object.findChild<QToolButton *>("qt_calendar_prevmonth");
QTest::mouseClick(button, Qt::LeftButton);
QCOMPARE(month > 1 ? month-1 : 12, object.monthShown());
button = object.findChild<QToolButton *>("qt_calendar_nextmonth");
QTest::mouseClick(button, Qt::LeftButton);
QCOMPARE(month, object.monthShown());
button = object.findChild<QToolButton *>("qt_calendar_yearbutton");
QTest::mouseClick(button, Qt::LeftButton, Qt::NoModifier, button->rect().center(), 2);
QVERIFY(!button->isVisible());
QSpinBox *spinbox = object.findChild<QSpinBox *>("qt_calendar_yearedit");
QTest::qWait(500);
QTest::keyClick(spinbox, '2');
QTest::keyClick(spinbox, '0');
QTest::keyClick(spinbox, '0');
QTest::keyClick(spinbox, '6');
QTest::qWait(500);
QWidget *widget = object.findChild<QWidget *>("qt_calendar_calendarview");
QTest::mouseMove(widget);
QTest::mouseClick(widget, Qt::LeftButton);
QCOMPARE(2006, object.yearShown());
object.setSelectedDate(selectedDate);
object.showSelectedDate();
QTest::keyClick(widget, Qt::Key_Down);
QVERIFY(selectedDate != object.selectedDate());
object.setDateRange(QDate(2006,1,1), QDate(2006,2,28));
object.setSelectedDate(QDate(2006,1,1));
object.showSelectedDate();
button = object.findChild<QToolButton *>("qt_calendar_prevmonth");
QTest::mouseClick(button, Qt::LeftButton);
QCOMPARE(1, object.monthShown());
button = object.findChild<QToolButton *>("qt_calendar_nextmonth");
QTest::mouseClick(button, Qt::LeftButton);
QCOMPARE(2, object.monthShown());
QTest::mouseClick(button, Qt::LeftButton);
QCOMPARE(2, object.monthShown());
}
示例14: retrieveValue
//.........这里部分代码省略.........
}
else
{
text = QString::null;
}
modified = true;
}
QSpinBox *sb = qobject_cast<QSpinBox *>( widget );
if ( sb )
{
text = QString::number( sb->value() );
}
QAbstractSlider *slider = qobject_cast<QAbstractSlider *>( widget );
if ( slider )
{
text = QString::number( slider->value() );
}
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox *>( widget );
if ( dsb )
{
text = QString::number( dsb->value() );
}
QCheckBox *ckb = qobject_cast<QCheckBox *>( widget );
if ( ckb )
{
QPair<QString, QString> states = vl->checkedState( idx );
text = ckb->isChecked() ? states.first : states.second;
}
QCalendarWidget *cw = qobject_cast<QCalendarWidget *>( widget );
if ( cw )
{
text = cw->selectedDate().toString();
}
le = widget->findChild<QLineEdit *>();
if ( le )
{
text = le->text();
}
switch ( theField.type() )
{
case QVariant::Int:
{
bool ok;
int myIntValue = text.toInt( &ok );
if ( ok && !text.isEmpty() )
{
value = QVariant( myIntValue );
modified = true;
}
else if ( modified )
{
value = QVariant();
}
}
break;
case QVariant::LongLong:
{
bool ok;
qlonglong myLongValue = text.toLong( &ok );
示例15: switch
//.........这里部分代码省略.........
return false;
sl->setValue( value.toInt() );
}
break;
}
else if ( myFieldType == QVariant::Double )
{
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox *>( editor );
if ( !dsb )
return false;
dsb->setValue( value.toDouble() );
}
}
case QgsVectorLayer::CheckBox:
{
QGroupBox *gb = qobject_cast<QGroupBox *>( editor );
if ( gb )
{
QPair<QString, QString> states = vl->checkedState( idx );
gb->setChecked( value == states.first );
break;
}
QCheckBox *cb = qobject_cast<QCheckBox *>( editor );
if ( cb )
{
QPair<QString, QString> states = vl->checkedState( idx );
cb->setChecked( value == states.first );
break;
}
}
// fall-through
case QgsVectorLayer::LineEdit:
case QgsVectorLayer::UniqueValuesEditable:
case QgsVectorLayer::Immutable:
case QgsVectorLayer::UuidGenerator:
default:
{
QLineEdit *le = qobject_cast<QLineEdit *>( editor );
QComboBox *cb = qobject_cast<QComboBox *>( editor );
QTextEdit *te = qobject_cast<QTextEdit *>( editor );
QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( editor );
if ( !le && ! cb && !te && !pte )
return false;
QString text;
if ( value.isNull() )
{
if ( myFieldType == QVariant::Int || myFieldType == QVariant::Double || myFieldType == QVariant::LongLong )
text = "";
else if ( editType == QgsVectorLayer::UuidGenerator )
text = QUuid::createUuid().toString();
else
text = nullValue;
}
else
{
text = value.toString();
}
if ( le )
le->setText( text );
if ( cb && cb->isEditable() )
cb->setEditText( text );
if ( te )
te->setHtml( text );
if ( pte )
pte->setPlainText( text );
}
break;
case QgsVectorLayer::FileName:
case QgsVectorLayer::Calendar:
{
QCalendarWidget *cw = qobject_cast<QCalendarWidget *>( editor );
if ( cw )
{
cw->setSelectedDate( value.toDate() );
break;
}
QLineEdit* le = qobject_cast<QLineEdit*>( editor );
if ( !le )
{
le = editor->findChild<QLineEdit *>();
}
if ( !le )
{
return false;
}
le->setText( value.toString() );
}
break;
}
return true;
}