D6937: Feature: add template for QDialog (pimp) with a UI File

Friedrich W. H. Kossebau noreply at phabricator.kde.org
Wed Jul 26 15:39:59 UTC 2017


kossebau added a comment.


  Get created template from https://share.kde.org/index.php/s/eimwxBm0TwqKG2G
  
  Example for created files:
  class name: Foo::BarDialog
  methods: constructor
  license: none
  options: window title -> "My empty dialog", button set -> "Close"
  
  bardialog.h:
  
    #ifndef FOO_BARDIALOG_H
    #define FOO_BARDIALOG_H
    
    #include <QDialog>
    
    namespace Foo
    {
    
    class BarDialogPrivate;
    
    /**
     * @todo write docs
     */
    class BarDialog : public QDialog
    {
        Q_OBJECT
    
    public:
        /**
         * Default constructor
         */
        BarDialog();
    
    private:
        BarDialogPrivate* const d_ptr;
        Q_DECLARE_PRIVATE ( BarDialog )
    };
    
    }
    
    #endif // FOO_BARDIALOG_H
  
  bardialog_p.h:
  
    #ifndef FOO_BARDIALOG_P_H
    #define FOO_BARDIALOG_P_H
    
    #include "ui_bardialog.h"
    
    namespace Foo
    {
    
    /**
     * @todo write docs
     */
    class BarDialogPrivate
    {
    public:
    
        Ui::BarDialog ui;
    };
    
    }
    
    #endif // FOO_BARDIALOG_P_H
  
  bardialog.cpp:
  
    #include "bardialog.h"
    #include "bardialog_p.h"
    
    using namespace Foo;
    
    BarDialog::BarDialog()
        : d_ptr(new BarDialogPrivate())
    {
        d_ptr->ui.setupUi(this);
    }
  
  bardialog.ui:
  
    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
     <class>BarDialog</class>
     <widget class="QDialog" name="BarDialog">
      <property name="geometry">
       <rect>
        <x>0</x>
        <y>0</y>
        <width>520</width>
        <height>300</height>
       </rect>
      </property>
      <property name="windowTitle">
       <string>My empty dialog</string>
      </property>
      <layout class="QVBoxLayout" name="verticalLayout" stretch="1,0">
       <item>
        <spacer name="verticalSpacer">
         <property name="orientation">
          <enum>Qt::Vertical</enum>
         </property>
        </spacer>
       </item>
       <item>
        <widget class="QDialogButtonBox" name="buttonBox">
         <property name="orientation">
          <enum>Qt::Horizontal</enum>
         </property>
         <property name="standardButtons">
          <set>QDialogButtonBox::Close</set>
         </property>
        </widget>
       </item>
      </layout>
     </widget>
     <resources/>
     <connections>
      <connection>
       <sender>buttonBox</sender>
       <signal>rejected()</signal>
       <receiver>BarDialog</receiver>
       <slot>reject()</slot>
      </connection>
     </connections>
    </ui>

REPOSITORY
  R32 KDevelop

REVISION DETAIL
  https://phabricator.kde.org/D6937

To: kossebau, #kdevelop
Cc: kdevelop-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20170726/5b9a7e77/attachment.html>


More information about the KDevelop-devel mailing list