showfile.cpp

来自「linux下KDE编写的程序」· C++ 代码 · 共 46 行

CPP
46
字号
/* showfile.cpp */#include <kapp.h>#include <qpushbutton.h>#include <qlayout.h>#include <qfiledialog.h>#include "showfile.h"#include "myicons.h"int main(int argc,char **argv){    KApplication app(argc,argv,"showfile");    QFileIconProvider *provider = new MyIcons();    QFileDialog::setIconProvider(provider);    ShowFile showfile;    showfile.show();    app.setMainWidget(&showfile);    return(app.exec());}ShowFile::ShowFile(QWidget *parent,const char *name)        : QWidget(parent,name){    QPushButton *button;    QVBoxLayout *box = new QVBoxLayout(this,0,3);    filelabel = new QLabel("",this);    filelabel->setAlignment(Qt::AlignHCenter);    box->addWidget(filelabel);    button = new QPushButton("Select File to Open",this);    box->addWidget(button);    connect(button,SIGNAL(clicked()),            this,SLOT(popupOpen()));    resize(10,10);    box->activate();}void ShowFile::popupOpen(){    QString name = QFileDialog::getOpenFileName("",            NULL,this);    if(!name.isEmpty()) {        filename = name;        filelabel->setText(filename);    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?