中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁(yè) > news >正文

wap手機(jī)網(wǎng)站開發(fā)百度如何購(gòu)買關(guān)鍵詞

wap手機(jī)網(wǎng)站開發(fā),百度如何購(gòu)買關(guān)鍵詞,wordpress 分享 微信二維碼,天河商城型網(wǎng)站建設(shè)Qt 是目前最先進(jìn)、最完整的跨平臺(tái)C開發(fā)工具。它不僅完全實(shí)現(xiàn)了一次編寫,所有平臺(tái)無(wú)差別運(yùn)行,更提供了幾乎所有開發(fā)過(guò)程中需要用到的工具。如今,Qt已被運(yùn)用于超過(guò)70個(gè)行業(yè)、數(shù)千家企業(yè),支持?jǐn)?shù)百萬(wàn)設(shè)備及應(yīng)用。 本文中的CalendarWi…

Qt?是目前最先進(jìn)、最完整的跨平臺(tái)C++開發(fā)工具。它不僅完全實(shí)現(xiàn)了一次編寫,所有平臺(tái)無(wú)差別運(yùn)行,更提供了幾乎所有開發(fā)過(guò)程中需要用到的工具。如今,Qt已被運(yùn)用于超過(guò)70個(gè)行業(yè)、數(shù)千家企業(yè),支持?jǐn)?shù)百萬(wàn)設(shè)備及應(yīng)用。

本文中的CalendarWidget示例展示了QCalendarWidget的用法。在上文中(點(diǎn)擊這里回顧>>),我們?yōu)榇蠹医榻B了窗口類的定義和部分窗口類的實(shí)現(xiàn),本節(jié)將繼續(xù)為大家講解窗口類的實(shí)現(xiàn)。

點(diǎn)擊獲取Qt Widget組件下載(Q技術(shù)交流:166830288)

QCalendarWidget一次顯示一個(gè)日歷月,并允許用戶選擇一個(gè)日期。日歷由四個(gè)組件組成:一個(gè)允許用戶更改顯示月份的導(dǎo)航欄、一個(gè)網(wǎng)格,其中每個(gè)單元格表示一個(gè)月中的一天,以及兩個(gè)顯示星期名稱和星期數(shù)字的標(biāo)題。

Calendar Widget示例顯示一個(gè)QCalendarWidget,并允許用戶使用QComboBoxes、QCheckBoxes和QDateEdits配置其外觀和操作,此外,用戶可以影響單個(gè)日期和標(biāo)題的格式。

本示例包含一個(gè)類Window,它創(chuàng)建并布局QCalendarWidget和其他讓用戶配置QCalendarWidget的小部件。

窗口類實(shí)現(xiàn)

現(xiàn)在讓我們看一下createDatesGroupBox()私有函數(shù):

void Window::createDatesGroupBox()
{
datesGroupBox = new QGroupBox(tr("Dates"));minimumDateEdit = new QDateEdit;
minimumDateEdit->setDisplayFormat("MMM d yyyy");
minimumDateEdit->setDateRange(calendar->minimumDate(),
calendar->maximumDate());
minimumDateEdit->setDate(calendar->minimumDate());minimumDateLabel = new QLabel(tr("&Minimum Date:"));
minimumDateLabel->setBuddy(minimumDateEdit);currentDateEdit = new QDateEdit;
currentDateEdit->setDisplayFormat("MMM d yyyy");
currentDateEdit->setDate(calendar->selectedDate());
currentDateEdit->setDateRange(calendar->minimumDate(),
calendar->maximumDate());currentDateLabel = new QLabel(tr("&Current Date:"));
currentDateLabel->setBuddy(currentDateEdit);maximumDateEdit = new QDateEdit;
maximumDateEdit->setDisplayFormat("MMM d yyyy");
maximumDateEdit->setDateRange(calendar->minimumDate(),
calendar->maximumDate());
maximumDateEdit->setDate(calendar->maximumDate());maximumDateLabel = new QLabel(tr("Ma&ximum Date:"));
maximumDateLabel->setBuddy(maximumDateEdit);

在這個(gè)函數(shù)中,我們創(chuàng)建Minimum Date, Maximum Date和Current Date編輯器小部件,它們控制日歷的最小日期、最大日期和所選日期。日歷的最小和最大日期已經(jīng)在createPrivewGroupBox()中設(shè)置;然后我們可以將小部件的默認(rèn)值設(shè)置為日歷值。

connect(currentDateEdit, &QDateEdit::dateChanged,
calendar, &QCalendarWidget::setSelectedDate);
connect(calendar, &QCalendarWidget::selectionChanged,
this, &Window::selectedDateChanged);
connect(minimumDateEdit, &QDateEdit::dateChanged,
this, &Window::minimumDateChanged);
connect(maximumDateEdit, &QDateEdit::dateChanged,
this, &Window::maximumDateChanged);
...
}

我們將currentDateEdit的dateChanged()信號(hào)直接連接到日歷的setSelectedDate()插槽,當(dāng)日歷所選日期發(fā)生更改時(shí),無(wú)論是由于用戶操作還是通過(guò)編程方式,selectedDateChanged()槽都會(huì)更新Current date編輯器,我們還需要在用戶 Minimum Date和Maximum Date時(shí)做出反應(yīng)。

下面是createTextFormatsGroup()函數(shù):

void Window::createTextFormatsGroupBox()
{
textFormatsGroupBox = new QGroupBox(tr("Text Formats"));weekdayColorCombo = createColorComboBox();
weekdayColorCombo->setCurrentIndex(
weekdayColorCombo->findText(tr("Black")));weekdayColorLabel = new QLabel(tr("&Weekday color:"));
weekdayColorLabel->setBuddy(weekdayColorCombo);weekendColorCombo = createColorComboBox();
weekendColorCombo->setCurrentIndex(
weekendColorCombo->findText(tr("Red")));weekendColorLabel = new QLabel(tr("Week&end color:"));
weekendColorLabel->setBuddy(weekendColorCombo);

我們使用createColorCombo()來(lái)設(shè)置工作日顏色和周末顏色組合框,它實(shí)例化了一個(gè)QComboBox,并用顏色("Red", "Blue"等)填充它。

headerTextFormatCombo = new QComboBox;
headerTextFormatCombo->addItem(tr("Bold"));
headerTextFormatCombo->addItem(tr("Italic"));
headerTextFormatCombo->addItem(tr("Plain"));headerTextFormatLabel = new QLabel(tr("&Header text:"));
headerTextFormatLabel->setBuddy(headerTextFormatCombo);firstFridayCheckBox = new QCheckBox(tr("&First Friday in blue"));mayFirstCheckBox = new QCheckBox(tr("May &1 in red"));

Header Text Format組合框允許用戶更改用于水平和垂直標(biāo)題的文本格式(粗體、斜體或普通), First Friday in blue和May 1 in red復(fù)選框會(huì)影響特定日期的呈現(xiàn)。

connect(weekdayColorCombo, &QComboBox::currentIndexChanged,
this, &Window::weekdayFormatChanged);
connect(weekdayColorCombo, &QComboBox::currentIndexChanged,
this, &Window::reformatCalendarPage);
connect(weekendColorCombo, &QComboBox::currentIndexChanged,
this, &Window::weekendFormatChanged);
connect(weekendColorCombo, &QComboBox::currentIndexChanged,
this, &Window::reformatCalendarPage);
connect(headerTextFormatCombo, &QComboBox::currentIndexChanged,
this, &Window::reformatHeaders);
connect(firstFridayCheckBox, &QCheckBox::toggled,
this, &Window::reformatCalendarPage);
connect(mayFirstCheckBox, &QCheckBox::toggled,
this, &Window::reformatCalendarPage);

我們將復(fù)選框和組合框連接到各種私有插槽,First Friday in blue和May 1 in red復(fù)選框連接到reformatCalendarPage(),該方法在日歷切換月份時(shí)也被調(diào)用。

...
reformatHeaders();
reformatCalendarPage();
}

在createTextFormatsGroupBox()的末尾,我們調(diào)用私有槽來(lái)同步QCalendarWidget與其他小部件。

現(xiàn)在我們已經(jīng)檢查了四個(gè)create…GroupBox()函數(shù),看一下其他私有函數(shù)和槽。

QComboBox *Window::createColorComboBox()
{
QComboBox *comboBox = new QComboBox;
comboBox->addItem(tr("Red"), QColor(Qt::red));
comboBox->addItem(tr("Blue"), QColor(Qt::blue));
comboBox->addItem(tr("Black"), QColor(Qt::black));
comboBox->addItem(tr("Magenta"), QColor(Qt::magenta));
return comboBox;
}

在createColorCombo()中,我們創(chuàng)建了一個(gè)組合框,并用標(biāo)準(zhǔn)顏色填充它,QComboBox::addItem()的第二個(gè)參數(shù)是一個(gè)存儲(chǔ)用戶數(shù)據(jù)的QVariant(在本例中是QColor對(duì)象)。

此函數(shù)用于設(shè)置Weekday Color和Weekend Color組合框。

void Window::firstDayChanged(int index)
{
calendar->setFirstDayOfWeek(Qt::DayOfWeek(
firstDayCombo->itemData(index).toInt()));
}

當(dāng)用戶更改組合框值上的Week starts時(shí),firstDayChanged()將使用組合框新值的索引調(diào)用。我們使用itemData()檢索與新的當(dāng)前項(xiàng)關(guān)聯(lián)的自定義數(shù)據(jù)項(xiàng),并將其轉(zhuǎn)換為Qt::DayOfWeek。

selectionModeChanged()、horizontalHeaderChanged()和verticalHeaderChanged()與firstDayChanged()非常相似,因此省略它們。

void Window::selectedDateChanged()
{
currentDateEdit->setDate(calendar->selectedDate());
}selectedDateChanged()更新Current Date編輯器,以反映QCalendarWidget的當(dāng)前狀態(tài)。void Window::minimumDateChanged(QDate date)
{
calendar->setMinimumDate(date);
maximumDateEdit->setDate(calendar->maximumDate());
}

當(dāng)用戶更改最小日期時(shí)告訴QCalenderWidget,還更新了Maximum Date編輯器,因?yàn)槿绻碌淖钚∪掌谕碛诋?dāng)前的最大日期,QCalendarWidget將自動(dòng)調(diào)整其最大日期以避免矛盾狀態(tài)。

void Window::maximumDateChanged(QDate date)
{
calendar->setMaximumDate(date);
minimumDateEdit->setDate(calendar->minimumDate());
}

maximumDateChanged()的實(shí)現(xiàn)類似于minimumDateChanged()。

void Window::weekdayFormatChanged()
{
QTextCharFormat format;format.setForeground(qvariant_cast<QColor>(
weekdayColorCombo->itemData(weekdayColorCombo->currentIndex())));
calendar->setWeekdayTextFormat(Qt::Monday, format);
calendar->setWeekdayTextFormat(Qt::Tuesday, format);
calendar->setWeekdayTextFormat(Qt::Wednesday, format);
calendar->setWeekdayTextFormat(Qt::Thursday, format);
calendar->setWeekdayTextFormat(Qt::Friday, format);
}

每個(gè)組合框項(xiàng)都有一個(gè)QColor對(duì)象作為與該項(xiàng)文本對(duì)應(yīng)的用戶數(shù)據(jù),從組合框中獲取顏色后,我們?cè)O(shè)置一周中每一天的文本格式。

日歷中列的文本格式為QTextCharFormat,除了前景色外,它還允許我們指定各種字符格式信息。在這個(gè)例子中,我們只展示了可能性的一個(gè)子集。

void Window::weekendFormatChanged()
{
QTextCharFormat format;format.setForeground(qvariant_cast<QColor>(
weekendColorCombo->itemData(weekendColorCombo->currentIndex())));
calendar->setWeekdayTextFormat(Qt::Saturday, format);
calendar->setWeekdayTextFormat(Qt::Sunday, format);
}

weekendFormatChanged()與weekdayFormatChanged()相同,不同之處是它影響的是周六和周日,而不是周一到周五。

當(dāng)用戶更改標(biāo)題的文本格式時(shí),將調(diào)用reformatHeaders()插槽。我們比較標(biāo)題文本格式組合框的當(dāng)前文本,以確定應(yīng)用哪種格式。(另一種選擇是將QTextCharFormat值存儲(chǔ)在組合框項(xiàng)旁邊。)

void Window::reformatCalendarPage()
{
QTextCharFormat mayFirstFormat;
const QDate mayFirst(calendar->yearShown(), 5, 1);QTextCharFormat firstFridayFormat;
QDate firstFriday(calendar->yearShown(), calendar->monthShown(), 1);
while (firstFriday.dayOfWeek() != Qt::Friday)
firstFriday = firstFriday.addDays(1);if (firstFridayCheckBox->isChecked()) {
firstFridayFormat.setForeground(Qt::blue);
} else { // Revert to regular colour for this day of the week.
Qt::DayOfWeek dayOfWeek(static_cast<Qt::DayOfWeek>(firstFriday.dayOfWeek()));
firstFridayFormat.setForeground(calendar->weekdayTextFormat(dayOfWeek).foreground());
}calendar->setDateTextFormat(firstFriday, firstFridayFormat);// When it is checked, "May First in Red" always takes precedence over "First Friday in Blue".
if (mayFirstCheckBox->isChecked()) {
mayFirstFormat.setForeground(Qt::red);
} else if (!firstFridayCheckBox->isChecked() || firstFriday != mayFirst) {
// We can now be certain we won't be resetting "May First in Red" when we restore
// may 1st's regular colour for this day of the week.
Qt::DayOfWeek dayOfWeek(static_cast<Qt::DayOfWeek>(mayFirst.dayOfWeek()));
calendar->setDateTextFormat(mayFirst, calendar->weekdayTextFormat(dayOfWeek));
}calendar->setDateTextFormat(mayFirst, mayFirstFormat);
}

在reformatCalendarPage()中,我們?cè)O(shè)置了該月的第一個(gè)星期五和當(dāng)年的5月1日的文本格式,實(shí)際使用的文本格式取決于選中了哪些復(fù)選框以及工作日/周末的格式。

QCalendarWidget允許我們使用setDateTextFormat()設(shè)置單個(gè)日期的文本格式,選擇在日歷頁(yè)面更改時(shí)設(shè)置日期格式-即顯示新的月份-以及工作日/周末格式更改時(shí)設(shè)置日期格式。我們檢查mayFirstCheckBox和firstDayCheckBox中的哪個(gè)被選中(如果有的話),并相應(yīng)地設(shè)置文本格式。

?

http://www.risenshineclean.com/news/50029.html

相關(guān)文章:

  • 幫人做網(wǎng)站怎么收費(fèi)b2b免費(fèi)發(fā)布網(wǎng)站大全
  • iis 做網(wǎng)站免費(fèi)網(wǎng)站建站頁(yè)面
  • 男女做那個(gè)暖暖網(wǎng)站百度標(biāo)注平臺(tái)怎么加入
  • 順德品牌網(wǎng)站建設(shè)優(yōu)惠友情鏈接是外鏈嗎
  • 自由策劃網(wǎng)站建設(shè)企業(yè)網(wǎng)絡(luò)推廣軟件
  • 徐州建設(shè)網(wǎng)站價(jià)格百度官網(wǎng)認(rèn)證多少錢
  • wordpress如何加菜單seo檢查工具
  • 湖北省建設(shè)質(zhì)量安全協(xié)會(huì)網(wǎng)站網(wǎng)站公司網(wǎng)站建設(shè)
  • 泰安正規(guī)的網(wǎng)站建設(shè)站長(zhǎng)工具收錄
  • 做購(gòu)物網(wǎng)站寫數(shù)據(jù)庫(kù)的流程網(wǎng)絡(luò)營(yíng)銷成功案例有哪些2022
  • 東營(yíng)企業(yè)網(wǎng)站排名seo服務(wù)外包報(bào)價(jià)
  • 網(wǎng)站創(chuàng)作規(guī)劃百度搜圖
  • 山東省城鄉(xiāng)建設(shè)廳官網(wǎng)seo經(jīng)典案例分析
  • 衡水wap網(wǎng)站建設(shè)會(huì)計(jì)培訓(xùn)班的費(fèi)用是多少
  • 可以查企業(yè)備案的網(wǎng)站最新軍事新聞事件今天
  • 深圳專業(yè)網(wǎng)站制作多少錢十大騙子教育培訓(xùn)機(jī)構(gòu)
  • 武漢設(shè)計(jì)網(wǎng)優(yōu)化seo系統(tǒng)
  • 國(guó)外做文化的網(wǎng)站如何搭建網(wǎng)站平臺(tái)
  • 水果網(wǎng)站設(shè)計(jì)論文營(yíng)銷案例分析報(bào)告模板
  • 建筑模板生產(chǎn)廠家東莞seo外包平臺(tái)
  • 福田附近網(wǎng)站建設(shè)怎么自己搭建網(wǎng)站
  • python做調(diào)查問(wèn)卷網(wǎng)站百度指數(shù)批量
  • 廣西南寧生活網(wǎng)百度推廣優(yōu)化
  • 廣東省城鄉(xiāng)與住房建設(shè)廳網(wǎng)站網(wǎng)站seo優(yōu)化培訓(xùn)
  • 羽毛球賽事策劃方案石家莊seo推廣公司
  • 唐山做網(wǎng)站建設(shè)公司搜索引擎數(shù)據(jù)庫(kù)
  • 如何規(guī)劃網(wǎng)站欄目建網(wǎng)站用什么軟件
  • 南陽(yáng)響應(yīng)式網(wǎng)站seo基礎(chǔ)入門
  • 江蘇煙草電商網(wǎng)站電商網(wǎng)站搭建
  • 泰安可以做網(wǎng)站的公司好搜網(wǎng)惠州seo