我手机为moto e6,qt版本2.3.8(网上很难搜到,不知为啥),有人破解了些sdk,现在可以用qt编很多程序了,我也很想学。现在还是菜鸟,只会写几个简单的部件,部件的功能不会弄(目前只会玩退出功能)。这里问个很菜的问题:
如图(我编译好在手机上运行的结果),要在窗口上放置2个qradiobutton,内容分别为,1个qcombobox,2个按钮分别为ok、cancel.要求点了ok按钮后在/tmp目录下生成文件choice.txt,内容为radiobutton和combobox的选择结果,然后退出QWidget.
ps:
1.各位编程是直接写代码还是用qt designer?
2.如何短时间学好qt?
这是手机sdk,其中ezx是moto在qt基础上改的.
ezx.rar (98 K) 下载次数:2
qt.rar (527 K) 下载次数:2 我写的源码:
#include <ZApplication.h>
#include <qwidget.h>
#include <zpushbutton.h>
#include <qcombobox.h>
#include <qbuttongroup.h>
#include <qradiobutton.h>
class MainWindow :public QWidget
{
public:
MainWindow();
private:
ZPushButton *pb1, *pb2;
QComboBox *combobox;
QButtonGroup *grpb;
QRadioButton *rb1, *rb2;
};
MainWindow::MainWindow()
{
setGeometry(30,40,200,240);
grpb=new QButtonGroup("radiobutton",this);
grpb->setGeometry(20,20,140,90);
rb1=new QRadioButton("button1",grpb);
rb1->move(20,20);
rb1->setChecked(true);
rb2=new QRadioButton("button2",grpb);
rb2->move(20,50);
combobox=new QComboBox(false,this);
combobox->setGeometry(20,130,160,35);
combobox->insertItem("choice1");
combobox->insertItem("choice2");
pb1=new ZPushButton(this);
pb1->setGeometry(0,210,100,30);
pb1->setText("ok");
pb2=new ZPushButton(this);
pb2->setGeometry(100,210,100,30);
pb2->setText("cancel");
//QObject::connect(pb1,SIGNAL(clicked()),this,SLOT(accept()));
QObject::connect(pb2,SIGNAL(clicked()),this,SLOT(close()));
}
int main( int argc, char **argv )
{
ZApplication a(argc, argv);
MainWindow Window;
a.setMainWidget(&Window);
Window.show();
a.exec();
}
[ 此帖被novesky在2009-04-03 23:47重新编辑 ]