Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

QT Designer mnala pomoc oko povezivanja .ui, .h i .cpp

[es] :: C/C++ programiranje :: QT Designer mnala pomoc oko povezivanja .ui, .h i .cpp

[ Pregleda: 2043 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

xxxrugby

Član broj: 16068
Poruke: 653
*.adsl.net.t-com.hr.

Sajt: www.zagreb-rugby.hr


Profil

icon QT Designer mnala pomoc oko povezivanja .ui, .h i .cpp25.08.2006. u 16:22 - pre 215 meseci
Pozdrav.

Procitao sam cijeli Tutorial i sve mi je ajde 85% jasno. I nemam problema s tim.

E sad al ocu iskoristit QT Designer radi lakseg povezivanja. Tj. u njemu sve lijepo napravim GUI a poslije povezujem.

E sad taj file.ui file iz QT Designera iskompajliram te dobijem file.h.

E sad da bi taj file.h mogao iskoristit trebam file.cpp

E sad jel ima nesto sta bi meni napravilo taj .cpp il ga moram cijelog rucno sam napisat.
Mislim ima pun kufer kod-a. Pa onda nevidim smisao QT Designera.
Mislim mogao sam sjest i sve to nakucat onda rucno u jedan .cpp. Jedino sta ce mi taj file.h pomocu pri brzoj kompajlaciji koda.

npr. imam
untitled.h
Code:
#ifndef UNTITLED_H
#define UNTITLED_H

#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QDialog>
#include <QtGui/QHBoxLayout>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QWidget>

class Ui_Dialog
{
public:
    QWidget *layoutWidget;
    QHBoxLayout *hboxLayout;
    QSpacerItem *spacerItem;
    QPushButton *okButton;
    QPushButton *cancelButton;

    void setupUi(QDialog *Dialog)
    {
    Dialog->setObjectName(QString::fromUtf8("Dialog"));
    Dialog->resize(QSize(400, 300).expandedTo(Dialog->minimumSizeHint()));
    layoutWidget = new QWidget(Dialog);
    layoutWidget->setObjectName(QString::fromUtf8("layoutWidget"));
    layoutWidget->setGeometry(QRect(20, 250, 351, 33));
    hboxLayout = new QHBoxLayout(layoutWidget);
    hboxLayout->setSpacing(6);
    hboxLayout->setMargin(0);
    hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
    spacerItem = new QSpacerItem(131, 31, QSizePolicy::Expanding, QSizePolicy::Minimum);

    hboxLayout->addItem(spacerItem);

    okButton = new QPushButton(layoutWidget);
    okButton->setObjectName(QString::fromUtf8("okButton"));

    hboxLayout->addWidget(okButton);

    cancelButton = new QPushButton(layoutWidget);
    cancelButton->setObjectName(QString::fromUtf8("cancelButton"));

    hboxLayout->addWidget(cancelButton);

    retranslateUi(Dialog);
    QObject::connect(okButton, SIGNAL(clicked()), Dialog, SLOT(accept()));
    QObject::connect(cancelButton, SIGNAL(clicked()), Dialog, SLOT(reject()));

    QMetaObject::connectSlotsByName(Dialog);
    } // setupUi

    void retranslateUi(QDialog *Dialog)
    {
    Dialog->setWindowTitle(QApplication::translate("Dialog", "Dialog", 0, QApplication::UnicodeUTF8));
    okButton->setText(QApplication::translate("Dialog", "OK", 0, QApplication::UnicodeUTF8));
    cancelButton->setText(QApplication::translate("Dialog", "Cancel", 0, QApplication::UnicodeUTF8));
    Q_UNUSED(Dialog);
    } // retranslateUi

};

namespace Ui {
    class Dialog: public Ui_Dialog {};
} // namespace Ui

#endif // UNTITLED_H


main.cpp
Code:
    #include "untitled.h"
    #include <QApplication>
    #include <QDialog>

   int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        QDialog *window = new QDialog;
        Ui::Dialog ui;
        ui.setupUi(window);

        window->show();
        return app.exec();
    }


untitled.ui
Code:
<ui version="4.0" >
 <author></author>
 <comment></comment>
 <exportmacro></exportmacro>
 <class>Dialog</class>
 <widget class="QDialog" name="Dialog" >
  <property name="geometry" >
   <rect>
    <x>0</x>
    <y>0</y>
    <width>400</width>
    <height>300</height>
   </rect>
  </property>
  <property name="windowTitle" >
   <string>Dialog</string>
  </property>
  <widget class="QWidget" name="layoutWidget" >
   <property name="geometry" >
    <rect>
     <x>20</x>
     <y>250</y>
     <width>351</width>
     <height>33</height>
    </rect>
   </property>
   <layout class="QHBoxLayout" >
    <property name="margin" >
     <number>0</number>
    </property>
    <property name="spacing" >
     <number>6</number>
    </property>
    <item>
     <spacer>
      <property name="orientation" >
       <enum>Qt::Horizontal</enum>
      </property>
      <property name="sizeHint" >
       <size>
        <width>131</width>
        <height>31</height>
       </size>
      </property>
     </spacer>
    </item>
    <item>
     <widget class="QPushButton" name="okButton" >
      <property name="text" >
       <string>OK</string>
      </property>
     </widget>
    </item>
    <item>
     <widget class="QPushButton" name="cancelButton" >
      <property name="text" >
       <string>Cancel</string>
      </property>
     </widget>
    </item>
   </layout>
  </widget>
 </widget>
 <pixmapfunction></pixmapfunction>
 <resources/>
 <connections>
  <connection>
   <sender>okButton</sender>
   <signal>clicked()</signal>
   <receiver>Dialog</receiver>
   <slot>accept()</slot>
   <hints>
    <hint type="sourcelabel" >
     <x>278</x>
     <y>253</y>
    </hint>
    <hint type="destinationlabel" >
     <x>96</x>
     <y>254</y>
    </hint>
   </hints>
  </connection>
  <connection>
   <sender>cancelButton</sender>
   <signal>clicked()</signal>
   <receiver>Dialog</receiver>
   <slot>reject()</slot>
   <hints>
    <hint type="sourcelabel" >
     <x>369</x>
     <y>253</y>
    </hint>
    <hint type="destinationlabel" >
     <x>179</x>
     <y>282</y>
    </hint>
   </hints>
  </connection>
 </connections>
</ui>


[Ovu poruku je menjao xxxrugby dana 25.08.2006. u 18:40 GMT+1]
xxxrugby: "We are all philosophers, when question is about politics!"
 
Odgovor na temu

xxxrugby

Član broj: 16068
Poruke: 653
*.adsl.net.t-com.hr.

Sajt: www.zagreb-rugby.hr


Profil

icon Re: QT Designer mnala pomoc oko povezivanja .ui, .h i .cpp27.08.2006. u 20:04 - pre 214 meseci
Sve nadjenjo.! Nista moze se poruka pobrisat.
xxxrugby: "We are all philosophers, when question is about politics!"
 
Odgovor na temu

[es] :: C/C++ programiranje :: QT Designer mnala pomoc oko povezivanja .ui, .h i .cpp

[ Pregleda: 2043 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.