Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
// map that can be initialized at declaration
template<typename K, typename V> struct MyMap :
public QMap<K,V>
{
MyMap<K,V> & add( K k, V v ) { (*this)[k] = v; return( *this ); }
};
// type of a funtion taking no parameter and returning a pointer to a QWidget
typedef QWidget * (* FCreateWidget) ();
struct Widget0 : public QWidget
{
Widget0() : QWidget() { setWindowTitle( "Widget0" ); }
// thist method is of type FCreateWidget
static QWidget * create() { return( new Widget0 ); }
};
struct Widget1 : public QWidget
{
Widget1() : QWidget() { setWindowTitle( "Widget1" ); }
// thist method is of type FCreateWidget
static QWidget * create() { return( new Widget1 ); }
};
struct Widget2 : public QWidget
{
Widget2() : QWidget() { setWindowTitle( "Widget2" ); }
// thist method is of type FCreateWidget
static QWidget * create() { return( new Widget2 ); }
};
// a map associating a class name to a creation function
static MyMap<QString,FCreateWidget> createMap = MyMap<QString,FCreateWidget>()
.add( "Widget0", Widget0::create )
.add( "Widget1", Widget1::create )
.add( "Widget2", Widget2::create );
int main( int ac, char * * av )
{
QApplication app( ac, av );
for( int i = 0; i < 10; i++ )
{
QString classe = QString( "Widget%1" ).arg( i );
if( FCreateWidget fn = createMap[classe] )
{
fn()->show();
}
}
return( app.exec() );
}
|
This post has been edited 1 times, last edit by "Nicolas SOUCHON" (May 2nd 2012, 9:17am)
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
1>------ Build started: Project: SpineStudio, Configuration: Debug x64 ------ 1>Compiling... 1>moc_AddImagesWorkAreaUI.cpp 1>ProcessStepList.cpp 1>ProcessStep.cpp 1>AddImagesWorkAreaUI.cpp 1>c:\projects\qt_products\spinestudio\viewer\source\ProcessWorkAreaUI.h(24) : error C2248: 'QWidget::QWidget' : cannot access private member declared in class 'QWidget' 1> c:\development\languages\qt\qt64\include\qtgui\../../src/gui/kernel/qwidget.h(806) : see declaration of 'QWidget::QWidget' 1> c:\development\languages\qt\qt64\include\qtgui\../../src/gui/kernel/qwidget.h(147) : see declaration of 'QWidget' 1> This diagnostic occurred in the compiler generated function 'ProcessWorkAreaUI::ProcessWorkAreaUI(const ProcessWorkAreaUI &)' 1>c:\projects\qt_products\spinestudio\viewer\source\ProcessWorkAreaUI.h(24) : error C2248: 'QWidget::QWidget' : cannot access private member declared in class 'QWidget' 1> c:\development\languages\qt\qt64\include\qtgui\../../src/gui/kernel/qwidget.h(806) : see declaration of 'QWidget::QWidget' 1> c:\development\languages\qt\qt64\include\qtgui\../../src/gui/kernel/qwidget.h(147) : see declaration of 'QWidget' 1> This diagnostic occurred in the compiler generated function 'ProcessWorkAreaUI::ProcessWorkAreaUI(const ProcessWorkAreaUI &)' 1>c:\projects\qt_products\spinestudio\viewer\source\ProcessWorkAreaUI.h(24) : error C2248: 'QWidget::QWidget' : cannot access private member declared in class 'QWidget' 1> c:\development\languages\qt\qt64\include\qtgui\../../src/gui/kernel/qwidget.h(806) : see declaration of 'QWidget::QWidget' 1> c:\development\languages\qt\qt64\include\qtgui\../../src/gui/kernel/qwidget.h(147) : see declaration of 'QWidget' 1> This diagnostic occurred in the compiler generated function 'ProcessWorkAreaUI::ProcessWorkAreaUI(const ProcessWorkAreaUI &)' 1>c:\projects\qt_products\spinestudio\viewer\source\ProcessWorkAreaUI.h(24) : error C2248: 'QWidget::QWidget' : cannot access private member declared in class 'QWidget' 1> c:\development\languages\qt\qt64\include\qtgui\../../src/gui/kernel/qwidget.h(806) : see declaration of 'QWidget::QWidget' 1> c:\development\languages\qt\qt64\include\qtgui\../../src/gui/kernel/qwidget.h(147) : see declaration of 'QWidget' 1> This diagnostic occurred in the compiler generated function 'ProcessWorkAreaUI::ProcessWorkAreaUI(const ProcessWorkAreaUI &)' 1>Build log was saved at "file://c:\Projects\QT_Products\SpineStudio\viewer\debug64\BuildLog.htm" 1>SpineStudio - 4 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 9 up-to-date, 0 skipped ========== |
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
// File: ProcessWorkAreaUI.cpp
// Purpose: Basic Ancestor class for all work area widgets
// Application Include Files
#include "ProcessWorkAreaUI.h"
/***************************************************************************/
/* Constructor. */
/***************************************************************************/
ProcessWorkAreaUI::ProcessWorkAreaUI(QWidget *parent)
: QWidget(parent)
{
// Create the dialog controls
m_ui.setupUi(this);
}
/***************************************************************************/
/* Destructor */
/***************************************************************************/
ProcessWorkAreaUI::~ProcessWorkAreaUI()
{
}
// File: ProcessWorkAreaUI.h
// Define statement to ensure that only this header
// file is included once
#ifndef PROCESSWORKAREAUI_H
#define PROCESSWORKAREAUI_H
// Include Files
#include <QWidget>
#include "ui_ProcessWorkAreaUI.h"
// Class Declaration
class ProcessWorkAreaUI : public QWidget
{
// Macros
Q_OBJECT
public:
// Constructors/Destructor
ProcessWorkAreaUI(QWidget *parent = 0);
~ProcessWorkAreaUI();
private:
// Variables
Ui::ProcessWorkAreaUIClass m_ui;
};
#endif // PROCESSWORKAREAUI_H
// File: AddImagesWorkAreaUI.cpp
// Purpose: General work area for adding images. Inherited from ProcessWorkAreaUI
// Application Include Files
#include "AddImagesWorkAreaUI.h"
/***************************************************************************/
/* Constructor. */
/***************************************************************************/
AddImagesWorkAreaUI::AddImagesWorkAreaUI(QWidget *parent)
:ProcessWorkAreaUI(parent)
{
m_ui.setupUi(this);
}
/***************************************************************************/
/* Destructor */
/***************************************************************************/
AddImagesWorkAreaUI::~AddImagesWorkAreaUI()
{
}
// File: AddImagesWorkAreaUI.h
// Define statement to ensure that only this header
// file is included once
#ifndef ADDIMAGESWORKAREAUI_H
#define ADDIMAGESWORKAREAUI_H
// Include Files
#include "ProcessWorkAreaUI.h"
#include "ui_AddImagesWorkAreaUI.h"
// Class Declaration
class AddImagesWorkAreaUI : public ProcessWorkAreaUI
{
// Macros
Q_OBJECT
public:
// Constructors/Destructor
Q_INVOKABLE AddImagesWorkAreaUI(QWidget *parent = 0);
~AddImagesWorkAreaUI();
private:
// Variables
Ui::AddImagesWorkAreaUIClass m_ui;
};
Q_DECLARE_METATYPE(ProcessWorkAreaUI)
#endif // ADDIMAGESWORKAREAUI_H
|
|
|
Source code |
1 |
ProcessWorkAreaUI::ProcessWorkAreaUI(const ProcessWorkAreaUI &) |
|
|
Source code |
1 |
explicit ProcessWorkAreaUI(QWidget *parent = 0); |
|
|
Source code |
1 2 |
private: ProcessWorkAreaUI(const ProcessWorkAreaUI &); |