Form->setObjectName(QString::fromUtf8(\ Form->resize(522, 388);
leftList = new QListWidget(Form);
leftList->setObjectName(QString::fromUtf8(\ leftList->setGeometry(QRect(10, 20, 211, 341)); rightList = new QListWidget(Form);
rightList->setObjectName(QString::fromUtf8(\ rightList->setGeometry(QRect(295, 20, 211, 341)); add = new QPushButton(Form);
add->setObjectName(QString::fromUtf8(\ add->setGeometry(QRect(230, 80, 51, 27)); remove = new QPushButton(Form);
remove->setObjectName(QString::fromUtf8(\ remove->setGeometry(QRect(230, 130, 51, 27)); addAll = new QPushButton(Form);
addAll->setObjectName(QString::fromUtf8(\ addAll->setGeometry(QRect(230, 180, 51, 27)); removeAll = new QPushButton(Form);
removeAll->setObjectName(QString::fromUtf8(\ removeAll->setGeometry(QRect(230, 230, 51, 27));
retranslateUi(Form);
QMetaObject::connectSlotsByName(Form); } // setupUi
void retranslateUi(QWidget *Form) {
Form->setWindowTitle(QApplication::translate(\QApplication::UnicodeUTF8));
add->setText(QApplication::translate(\QApplication::UnicodeUTF8));
remove->setText(QApplication::translate(\QApplication::UnicodeUTF8));
\
0,
\
0,
\
0,
addAll->setText(QApplication::translate(\QApplication::UnicodeUTF8));
removeAll->setText(QApplication::translate(\QApplication::UnicodeUTF8)); Q_UNUSED(Form); } // retranslateUi };
namespace Ui {
class Form: public Ui_Form {}; } // namespace Ui
QT_END_NAMESPACE
#endif // UI_LISTBOX_H
\0,
\0,
listbox.h
#ifndef _LISTBOX_H_ #define _LISTBOX_H_
#include \
class CListBox:public QWidget,public Ui_Form {
Q_OBJECT public:
CListBox(QWidget* parent=0);
private slots: void add(); void addAll(); void remove();
void removeAll(); }; #endif
listbox.cpp
#include
CListBox::CListBox(QWidget* parent):QWidget(parent) {
setupUi(this); for(int i=1;i<=6;i++)
leftList->addItem(tr(\条目%1\
connect(addBtn,SIGNAL(clicked()),this,SLOT(add())); connect(addAllBtn,SIGNAL(clicked()),this,SLOT(addAll())); connect(removeBtn,SIGNAL(clicked()),this,SLOT(remove())); connect(removeAllBtn,SIGNAL(clicked()),this,SLOT(removeAll())); }
void CListBox::add() {
QListWidgetItem* item=leftList->currentItem(); if(item==0) return;
rightList->addItem(item->text()); leftList->takeItem(leftList->currentRow()); }
void CListBox::addAll() {
for(int i=0;i
QListWidgetItem* item=leftList->item(i); rightList->addItem(item->text()); }
leftList->clear(); }
void CListBox::remove() {
QListWidgetItem* item=rightList->currentItem(); if(item==0) return;
leftList->addItem(item->text());
rightList->takeItem(rightList->currentRow()); }
void CListBox::removeAll() {
for(int i=0;i
QListWidgetItem* item=rightList->item(i); leftList->addItem(item->text()); }
rightList->clear(); }
int main(int argc,char* argv[]) {
QApplication app(argc,argv);
QTextCodec::setCodecForTr(QTextCodec::codecForLocale()); CListBox dlg;
dlg.show(); return app.exec(); }
11.QApplication的主要作用是什么?
QApplication对象管理QtGui应用程序的控制流程和主要的设置参数 12.请写一个调用消息对话框提示报错的程序
QMessageBox::waring(this,tr(“警告”),tr(“用户名或密码错误!”),QMessageBox::Yes) 13.QT都提供哪些标准对话框以供使用,他们实现什么功能
9个QColorDialog 颜色对话框,能够允许用户选择颜色、QErrorMessage显示错误信息、QFileDialog文件对话框,能够允许用户选的一个或者多个文件以及目录、QFontDialog字体对话框,允许用户选择/设置字体、QInputDialog输入对话框,允许用户进行简单的输入、QPageSetupDialog叶设置对话框,配置与页相关的打印机选项、QProgressDialog 进度对话框 指示一个长时间操作的工作进度,以提示用户该操作是否已经停止、QPrintDialog 打印对话框,配置打印机,可以允许用户选择可用的打印机、QMessageBox。 14.QT中怎么在一个窗口中获得另一个窗口的指针 Class A {
B b; P; } b.p
Class B {
Public:
getName(char *p) {
d=p;
}
}
b.getName(this->p);
什么是Qt,有什么优点? Qt是有Troltech公司开发的一个多平台的c++图形用户界面程序框架。
优点:它提供给应用程序开发者建立艺术级的图形用户界面所需的所有功能。Qt是完全面向对象的很容易扩展,并且允许真正地组件编程。 可移植性:QT不仅适用于UNIX,同样适用于Windows。为了同时拥有世界上几百万UNIX用户以及几百万的Windows用户,最好的办法是采用一个既适用于UNIX,又适用于Windows的GUI工具包,其答案是QT。
易用性:QT是一个C++工具包,它由几百个C++类构成,你在程序中可以使用这些类。因为C++是面向对象的编程语言,而QT是基于C++构造,所以QT具有OOP的所有优点
运行速度:QT非常容易使用,且也具有很快的速度。QT的易用性和快速是密不可分的。这一优点要归功于QT开发者的辛苦工作,他们花费了大量的时间来优化他们的产品。QT比其他许多GUI工具包运行速度快的原因是其实现方式。QT是一个GUI仿真工具包,即它不使用本地工具包作调用,而是使用各自平台上的低级绘图函数,从而提高程序速度。
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库QT理论试题及答案(5)在线全文阅读。
相关推荐: