| /*--- form.h ---*/ #ifndef FORM_H #define FORM_H #include <QtGui> class Form : public QDialog { Q_OBJECT public: QPushButton *btnMesaj; QPushButton *btnAc; QPushButton *btnTemizle; QPushButton *btnCik; QLabel *lblMesaj; QLabel *lblAc; QLabel *lblTemizle; QTextEdit *yazi; QDirModel *model; QTreeView *treeDosyalar; Form(); public slots: void mesajGoster() { QMessageBox::information(this, "Mesaj", "Layer 'lar o kadar da zor degilmis :)"); } void dosyaAc() { QString dosyaYolu = QFileDialog::getOpenFileName(this); QFile dosya(dosyaYolu); dosya.open(QFile::ReadOnly | QFile::Text); QTextStream ts(&dosya); yazi->setPlainText(ts.readAll()); } void treeAc(const QModelIndex qm) { QDirModel *yol= new QDirModel(); QFile dosya_(yol->filePath(qm)); dosya_.open(QFile::ReadOnly | QFile::Text); QTextStream ts_(&dosya_); yazi->setPlainText(ts_.readAll()); } }; #endif |
| /*--- form.cpp ---*/ #include "form.h" Form::Form() { resize(600,600); QGridLayout *gLayout= new QGridLayout(); lblMesaj = new QLabel("Mesaj goster :"); gLayout->addWidget(lblMesaj,0,0); lblAc = new QLabel("Dosya Ac :"); gLayout->addWidget(lblAc,1,0); lblTemizle = new QLabel("Temizle :"); gLayout->addWidget(lblTemizle,2,0); btnMesaj = new QPushButton("Mesaj Goster"); gLayout->addWidget(btnMesaj,0,1); btnAc = new QPushButton("Dosya Ac"); gLayout->addWidget(btnAc,1,1); btnTemizle = new QPushButton("Temizle"); gLayout->addWidget(btnTemizle,2,1); treeDosyalar = new QTreeView(); model = new QDirModel(); treeDosyalar->setModel(model); gLayout->addWidget(treeDosyalar,0,2,14,1); yazi = new QTextEdit(); yazi->setPlainText("Temizle butonuna basarsan bu yazi silinir :)"); yazi->resize(550,300); gLayout->addWidget(yazi,15,0,1,3); QHBoxLayout *hLayout = new QHBoxLayout(); btnCik = new QPushButton("Cik Git"); hLayout->addStretch(10); hLayout->addWidget(btnCik,Qt::AlignRight); QVBoxLayout *aLayout = new QVBoxLayout(); aLayout->addLayout(gLayout); aLayout->addLayout(hLayout); setLayout(aLayout); connect(btnMesaj ,SIGNAL(clicked()),this,SLOT(mesajGoster())); connect(btnAc ,SIGNAL(clicked()),this,SLOT(dosyaAc())); connect(btnTemizle ,SIGNAL(clicked()),yazi,SLOT(clear())); connect(btnCik ,SIGNAL(clicked()),this,SLOT(reject())); connect(treeDosyalar, SIGNAL(doubleClicked(QModelIndex )),this, SLOT(treeAc(const QModelIndex ))); } |
| /*---
main.cpp ---*/ #include "form.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication app (argc,argv); Form form; form.show(); return app.exec(); } |

Tüm telif hakları aksi özellikle belirtilmediği sürece sahibine aittir. Belge içinde geçen herhangi bir terim bir ticarî isim ya da kuruma itibar kazandırma olarak algılanmamalıdır. Bir ürün ya da markanın kullanılmış olması ona onay verildiği anlamında görülmemelidir.