snippets / MaviAtes / 

All MaviAtes's snippets (1)

  1. c++ QT saatin yaninda balon açma örnegi

    C++ ile QT için signal ve slot kullanmaya örnek bir proje

      1 //////////////////////////////////////////////////////   Main.cpp
    2 //////////////////////////////////////////////////////
    3
    4 #include <QtGui>
    5 #include "pencere.h"
    6
    7 int main(int argc, char *argv[])
    8 {
    9 QApplication app(argc, argv);
    10
    11 if (!QSystemTrayIcon::isSystemTrayAvailable()) {
    12 QMessageBox::critical(0, QObject::tr("Uyari!"),
    13 QObject::tr("Bu bilgisayarda herhangi bir "
    14 "görev bölmesi bulunamad?."));
    15 return 1;
    16 }
    17
    18
    19 AnaPencere p;
    20
    21 p.show();
    22 return app.exec();
    23 }
    24
    25 ////////////////////////////////////////////////////// pencere.h
    26 //////////////////////////////////////////////////////
    27
    28 #include <QMainWindow>
    29 #include <QSystemTrayIcon>
    30 #include "ui_pencere.h"
    31
    32 class AnaPencere:public QMainWindow, Ui::MainWindow
    33 {
    34 Q_OBJECT
    35 public:
    36 QSystemTrayIcon *SistemTepsiSimgesi;
    37
    38 //kurucu fonksiyon
    39 AnaPencere():QMainWindow()
    40 {
    41 setupUi(this);
    42 connect(dugme, SIGNAL(clicked()), this, SLOT(balonac()));
    43
    44 SistemTepsisineSimgeKoy();
    45 }
    46
    47
    48
    49 public slots:
    50 void balonac()
    51 {
    52 // bu slot dugmeye basinca calisacak
    53 QSystemTrayIcon::MessageIcon ipucusimgesi = QSystemTrayIcon::MessageIcon(1);
    54 SistemTepsiSimgesi->showMessage(baslik->text(), ileti->toPlainText(), ipucusimgesi, 5000);
    55 }
    56
    57 void AnaPencere::SistemTepsisineSimgeKoy()
    58 {
    59 //Buradan simgeye sa? tu? menüsü eklenebilir.
    60 SistemTepsiSimgesi = new QSystemTrayIcon(this);
    61 SistemTepsiSimgesi->show();
    62 SistemTepsiSimgesi->setIcon(QIcon(QString::fromUtf8(":/simgeler/resimler/heart.svg")));
    63 }
    64
    65
    66 };
    67
    68
    69 ////////////////////////////////////////////////////// pencere.ui
    70 //////////////////////////////////////////////////////
    71
    72 <ui version="4.0" >
    73 <class>MainWindow</class>
    74 <widget class="QMainWindow" name="MainWindow" >
    75 <property name="geometry" >
    76 <rect>
    77 <x>0</x>
    78 <y>0</y>
    79 <width>349</width>
    80 <height>265</height>
    81 </rect>
    82 </property>
    83 <property name="windowTitle" >
    84 <string>Pencere</string>
    85 </property>
    86 <property name="windowIcon" >
    87 <iconset resource="resim_kaynagi.qrc" >:/simgeler/resimler/bad.svg</iconset>
    88 </property>
    89 <widget class="QWidget" name="centralwidget" >
    90 <widget class="QLabel" name="etiket1" >
    91 <property name="geometry" >
    92 <rect>
    93 <x>10</x>
    94 <y>20</y>
    95 <width>44</width>
    96 <height>18</height>
    97 </rect>
    98 </property>
    99 <property name="text" >
    100 <string>Ba?l?k :</string>
    101 </property>
    102 </widget>
    103 <widget class="QLabel" name="etiket2" >
    104 <property name="geometry" >
    105 <rect>
    106 <x>20</x>
    107 <y>60</y>
    108 <width>31</width>
    109 <height>18</height>
    110 </rect>
    111 </property>
    112 <property name="text" >
    113 <string>?leti :</string>
    114 </property>
    115 </widget>
    116 <widget class="QLineEdit" name="baslik" >
    117 <property name="geometry" >
    118 <rect>
    119 <x>80</x>
    120 <y>20</y>
    121 <width>251</width>
    122 <height>23</height>
    123 </rect>
    124 </property>
    125 </widget>
    126 <widget class="QTextEdit" name="ileti" >
    127 <property name="geometry" >
    128 <rect>
    129 <x>80</x>
    130 <y>60</y>
    131 <width>251</width>
    132 <height>141</height>
    133 </rect>
    134 </property>
    135 </widget>
    136 <widget class="QPushButton" name="dugme" >
    137 <property name="enabled" >
    138 <bool>true</bool>
    139 </property>
    140 <property name="geometry" >
    141 <rect>
    142 <x>230</x>
    143 <y>220</y>
    144 <width>101</width>
    145 <height>27</height>
    146 </rect>
    147 </property>
    148 <property name="text" >
    149 <string>Göster</string>
    150 </property>
    151 </widget>
    152 </widget>
    153 </widget>
    154 <resources>
    155 <include location="resim_kaynagi.qrc" />
    156 </resources>
    157 <connections/>
    158 </ui>
    159
    160
    161 ////////////////////////////////////////////////////// resim_kaynagi.qrc
    162 ////////////////////////////////////////////////////// Bu çok önemli degil, saatin yanina simge koymak için kullanmistim.
    163 ////////////////////////////////////////////////////// internetten herhangi bir svg uzantili resim bulup koyun. ben wikipedia 'dan bulmustum.
    164
    165
    166 <RCC>
    167 <qresource prefix="/simgeler" >
    168 <file>resimler/bad.svg</file>
    169 <file>resimler/heart.svg</file>
    170 <file>resimler/trash.svg</file>
    171 </qresource>
    172 </RCC>
    first posted by MaviAtes to c++ c++ qt4 qmake-qt4 balon ... saved by 1 person ... 0 comments ... 4 months, 2 weeks
showing 10, 25, 50 items per pages

Pages : 1