17 , m_settings(
"BHV",
"MyProgram")
20 m_ptxt =
new QTextEdit;
21 m_pcbo =
new QComboBox;
22 m_pchk =
new QCheckBox(
"Disable edit");
24 m_pcbo->addItem(
"Classic");
25 m_pcbo->addItem(
"Borland");
30 SIGNAL(activated(
int)),
36 QVBoxLayout* pvbxLayout =
new QVBoxLayout;
37 QHBoxLayout* phbxLayout =
new QHBoxLayout;
39 pvbxLayout->setContentsMargins(5, 5, 5, 5);
40 phbxLayout->setSpacing(15);
41 pvbxLayout->setSpacing(15);
42 pvbxLayout->addWidget(m_plbl);
43 pvbxLayout->addWidget(m_ptxt);
44 phbxLayout->addWidget(m_pcbo);
45 phbxLayout->addWidget(m_pchk);
47 pvbxLayout->addLayout(phbxLayout);
48 setLayout(pvbxLayout);
62 m_settings.beginGroup(
"/Settings");
64 QString strText = m_settings.value(
"/text",
"").toString();
65 int nWidth = m_settings.value(
"/width", width()).toInt();
66 int nHeight = m_settings.value(
"/height", height()).toInt();
67 int nComboItem = m_settings.value(
"/highlight", 0).toInt();
68 bool bEdit = m_settings.value(
"/edit",
false).toBool();
70 m_nCounter = m_settings.value(
"/counter", 1).toInt();
72 QString str = QString().setNum(m_nCounter++);
73 m_plbl->setText(
"This program has been started " + str +
" times");
75 m_ptxt->setPlainText(strText);
77 resize(nWidth, nHeight);
79 m_pchk->setChecked(bEdit);
82 m_pcbo->setCurrentIndex(nComboItem);
85 m_settings.endGroup();
91 m_settings.beginGroup(
"/Settings");
92 m_settings.setValue(
"/counter", m_nCounter);
93 m_settings.setValue(
"/text", m_ptxt->toPlainText());
94 m_settings.setValue(
"/width", width());
95 m_settings.setValue(
"/height", height());
96 m_settings.setValue(
"/highlight", m_pcbo->currentIndex());
97 m_settings.setValue(
"/edit", m_pchk->isChecked());
98 m_settings.endGroup();
104 m_ptxt->setEnabled(!m_pchk->isChecked());
110 QPalette pal = m_ptxt->palette();
111 pal.setColor(QPalette::Active,
113 n ? Qt::darkBlue : Qt::white
115 pal.setColor(QPalette::Active,
117 n ? Qt::yellow : Qt::black
119 m_ptxt->setPalette(pal);
void slotCheckBoxClicked()
MyProgram(QWidget *pwgt=0)
void slotComboBoxActivated(int)