TestWidget.cpp

#include "TestWidget.h"

#include "OfficeContainer.h"

DemoTestWidget::DemoTestWidget(QWidget *parent /*= NULL*/)
{
    initUI();
    initConnect();
    this->showMaximized();
}

DemoTestWidget::~DemoTestWidget()
{

}

void DemoTestWidget::initUI()
{
    pLblPath    = new QLabel(tr("Path:"),this);
    pTxtPath    = new QLineEdit(this);
    pBtnOpen    = new QPushButton(tr("Open"),this);
    pBtnSelect  = new QPushButton(tr("Select"),this);
    pBtnClose   = new QPushButton(tr("Close"),this);
    pComBox     = new QComboBox(this);

    /*
    officeDialogNew            = 0,
        officeDialogOpen           = 1,
        officeDialogSave           = 2,
        officeDialogSaveCopy       = 3,
        officeDialogPrint          = 4,
        officeDialogPageSetup      = 5,
        officeDialogProperties     = 6
    */
    pComBox->addItem("officeDialogNew");
    pComBox->addItem("officeDialogOpen");
    pComBox->addItem("officeDialogSave");
    pComBox->addItem("officeDialogSaveCopy");
    pComBox->addItem("officeDialogPrint");
    pComBox->addItem("officeDialogPageSetup");
    pComBox->addItem("officeDialogProperties");
    pBtnShowDlg = new QPushButton(tr("ShowDlg"),this);

    QHBoxLayout *hly001 = new QHBoxLayout();
    hly001->addWidget(pLblPath);
    hly001->addWidget(pTxtPath);
    hly001->addWidget(pBtnSelect);
    hly001->addWidget(pBtnOpen);
    hly001->addWidget(pBtnClose);
    hly001->addWidget(pComBox);
    hly001->addWidget(pBtnShowDlg);
    pCentrelWgt = new QWidget(this);

    QVBoxLayout *vly010 = new QVBoxLayout(this);
    vly010->addLayout(hly001);
    vly010->addWidget(pCentrelWgt,1);

    pOfficeContainer    = new OfficeContainer(this);
    QVBoxLayout *vly0010 = new QVBoxLayout(pCentrelWgt);//vly0010的父指针是pCentrelWgt,故QVBoxLayout位于pCentrelWgt内部
    vly0010->addWidget(pOfficeContainer,1);


}

void DemoTestWidget::initConnect()
{
    BUTTON_ACT(pBtnOpen,sltBtnOpen());
    BUTTON_ACT(pBtnSelect,sltBtnSelect());
    BUTTON_ACT(pBtnClose,sltBtnClose());
    BUTTON_ACT(pBtnShowDlg,sltBtnShowDlg());
}


void DemoTestWidget::sltBtnOpen()
{
    QString strPath = pTxtPath->text();
    if (!strPath.isEmpty())
    {
        QVariant v(strPath); //!!!!
        pOfficeContainer->Open(v);
    }
    qDebug() << "Btn Open";
}

void DemoTestWidget::sltBtnSelect()
{
    QString filePath = QFileDialog::getOpenFileName(this,tr("Select Word"),"",tr("Word (*.doc;*.docx;*.docm);;Excel (*.xls;*.xlsx;*.xlsm;*.xlsb);;PPT (*.ppt;*.pptx;*.pptm)"));
    if (filePath.isEmpty())
    {
        //emit sigUpdateMsg("未选择Word文件");
    }
    else
    {
        pTxtPath->setText(filePath);
    }
    qDebug() << "Btn Select";
}

void DemoTestWidget::sltBtnClose()
{
    pOfficeContainer->Close();
}

void DemoTestWidget::sltBtnShowDlg()
{
    int index = pComBox->currentIndex();

    pOfficeContainer->ShowDialog((OfficeContainer::DialogType)(index));
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值