for A1200, E6
Because of EZX SDK is not 100% complete. so everybody should face problem when try to create widget on screen. I start this thread for sharing experience about create EZX Widgets. This can lead to a nearly complete EZX SDK and Document them.
First I create a demo for ZPushButton. ZPushButton is derive from QToolButton. and I found 3 of them in the header file.
Quote:
ZPushButton in ZPushButton.h
UTIL_PushButton in ezxutilpushbutton.h
UTIL_PushButton in UTIL_PushButton.h
|
I can create only ZPushButton on screen. both UTIL_PushButton cause a segmentation fault error.
when create ZPushButton with no Resource ID. ZPushButton dispaly itself a CST Button. Its can be resize to any width.
Code:
ZPushButton *normal = new ZPushButton( this, 0 );
But when create ZPushButton
with resource ID
Code:
ZPushButton *rew = new ZPushButton( "MessCe_Rew", this );
ZPushButton will load all set of resource id (normal, action, disable, ...) from iconres.ezx or skin file and display itself. but ZPushButton does not resize resource id or resize itself to fit a resource. It need a layout manager do it or by coding.
Here is my button demo.
Code:
// HelloButton : HelloButton.h
// EZX demo for Button Widget.
// by eakrin @ gmail.com
// 2008 Mar 07
#ifndef __HELLOBUTTON__
#define __HELLOBUTTON__
#include <ZMainWidget.h>
class HelloButton : public ZMainWidget
{
Q_OBJECT
public:
HelloButton();
~HelloButton();
public slots:
void showDialog();
};
#endif // __HELLOBUTTON
Code:
// HelloButton : HelloButton.cpp
// EZX demo for Button Widget.
// by eakrin @ gmail.com
// 2008 Mar 07
#include "HelloButton.h"
#include <ZApplication.h>
#include <ZMainwidget.h>
#include <ZPushButton.h>
#include <ZMessageBox.h>
#include <ezxutilcst.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qframe.h>
HelloButton::HelloButton ()
: ZMainWidget( false, NULL, "ButtonTester", 0 )
{
// Create CST widget.
UTIL_CST *cst = new UTIL_CST( this, "Test Buttons" );
setCSTWidget( cst );
cst->show();
// Create CST buttons.
ZPushButton *btn;
btn = cst->getRightBtn();
connect( btn, SLOT( clicked() ), qApp, SLOT( slotQuickQuit() ) );
// Create content Layout.
QVBoxLayout *contentLayout = new QVBoxLayout ( this->getContentWidget( true ) );
// Create Testing Resource Button from iconres.ezx.
QHBoxLayout *layout1 = new QHBoxLayout;
QLabel *label1 = new QLabel( "Test ZPushButton :", this, "label1" );
ZPushButton *btn1 = new ZPushButton( "InSet_Picker_Date", this);
//btn1->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
//btn1->resize( 100, 28 );
connect( btn1, SIGNAL( clicked() ), this, SLOT( showDialog() ) );
layout1->addWidget( label1 );
layout1->addStretch();
layout1->addWidget( btn1 );
contentLayout->addLayout( layout1 );
// Create Player buttons.
QHBoxLayout *player = new QHBoxLayout;
ZPushButton *rew = new ZPushButton( "MessCe_Rew", this );
ZPushButton *play = new ZPushButton( "MessCe_Msg_Play", this );
ZPushButton *pause = new ZPushButton( "MessCe_Msg_Pause", this );
ZPushButton *fwd = new ZPushButton( "MessCe_Fast_Fwd", this );
// Toggle Button Does not work.
// play->setToggleButton( TRUE );
player->addWidget( rew );
player->addStretch();
player->addWidget( play );
player->addStretch();
player->addWidget( pause );
player->addStretch();
player->addWidget( fwd );
contentLayout->addLayout( player );
connect( rew, SIGNAL( clicked() ), this, SLOT( showDialog() ) );
connect( play, SIGNAL( clicked() ), this, SLOT( showDialog() ) );
connect( pause, SIGNAL( clicked() ), this, SLOT( showDialog() ) );
connect( fwd, SIGNAL( clicked() ), this, SLOT( showDialog() ) );
// Create Normal button style -> only CST Button can stretch resouce ID button cannot.
ZPushButton *normal = new ZPushButton( this, 0 );
normal->setText( "No resource" );
normal->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
contentLayout->addWidget( normal );
normal->setGeometry( 120, 0, 110, 35 );
connect( normal, SIGNAL( clicked() ), this, SLOT( showDialog() ) );
}
HelloButton::~HelloButton()
{
}
void HelloButton::showDialog()
{
ZMessageBox::information( this, NULL, "Test Push Button", "Ok" );
}
Code:
// HelloButton : main.cpp
// EZX demo for Button Widget.
// by eakrin @ gmail.com
// 2008 Mar 07
#include <ZApplication.h>
#include "HelloButton.h"
int main( int argc, char** argv )
{
ZApplication app( argc, argv );
HelloButton *mw = new HelloButton();
app.showMainWidget(mw);
return app.exec();
}
PS. Cannot create Toggle button with ZPushButton. because setToggleButton and setToggleType are protected and does not derive from QButton to ZPushButton.