Fatihul Ulum Community of Knowledge
Would you like to react to this message? Create an account in a few clicks or log in to continue.

QComboBox_sederhana

Go down

QComboBox_sederhana Empty QComboBox_sederhana

Post  cpp Tue Nov 24, 2009 5:06 pm

//QComboBox

gui.h
Code:

#include <QtGui>
class combo : public QWidget
{
   Q_OBJECT
   public :
   combo (QWidget *parent = 0);
   QComboBox *pilih;
   QPushButton *tekan;
   QLineEdit *edit;
   QVBoxLayout *lay;
      
   public slots :
   void HASIL ();
};


gui.cpp

Code:

#include <gui.h>
#include <QApplication>

combo :: combo (QWidget *parent ) : QWidget (parent)
{
   lay = new QVBoxLayout;//layout vertical
   tekan = new QPushButton ("OK deh");
   edit = new QLineEdit;
   pilih = new QComboBox;
   
   //menambah tulisan pada QComboBox
   pilih->addItem("Ubuntu");
   pilih->addItem("Fedora");
   pilih->addItem("Kubuntu");
   pilih->addItem("Slackware");
   pilih->addItem("Windows");
   pilih->addItem("Mandriva");   
   
   //memasukkan QPushButton, QLineEdit dan QComboBox ke QVBoxLayout
   lay->addWidget(pilih);
   lay->addWidget(tekan);
   lay->addWidget(edit);
   
   //memasukkan QVBoxLayout ke QWidget
   this->setLayout(lay);
   
   //menghubungkan QPushButton ke fungsi slot HASIL ()
   connect(tekan,SIGNAL (clicked()),this,SLOT(HASIL()));
}
void combo :: HASIL ()
{
   QString tulisan = pilih->currentText();
   edit->setText(tulisan);
}
int main (int ppfu, char **fudc)
{
   QApplication app (ppfu,fudc);
   combo __combo;
   __combo.show();
   return app.exec();
}
//itofu

cpp
Pejuang
Pejuang

Jumlah posting : 35
Registration date : 15.03.09

Kembali Ke Atas Go down

Kembali Ke Atas


 
Permissions in this forum:
Anda tidak dapat menjawab topik