tabdlg.h:
 
InBlock.gif#ifndef __TABDLG_H__
InBlock.gif#define __TABDLG_H__
InBlock.gif
InBlock.gif#include <QDialog>
InBlock.gif
InBlock.gif class QWidget;
InBlock.gif class QFileInfo;
InBlock.gif class QTabWidget;
InBlock.gif class QDialogButtonBox;
InBlock.gif
InBlock.gif //常规选项卡
InBlock.gif class GeneralTab : public QWidget
InBlock.gif{
InBlock.gif        Q_OBJECT
InBlock.gif
InBlock.gif public:
InBlock.gif        GeneralTab( const QFileInfo &fileInfo, QWidget *parent = 0);
InBlock.gif};
InBlock.gif
InBlock.gif //许可权限
InBlock.gif class PermissionsTab : public QWidget
InBlock.gif{
InBlock.gif        Q_OBJECT
InBlock.gif
InBlock.gif public:
InBlock.gif        PermissionsTab( const QFileInfo &fileInfo, QWidget *parent = 0);
InBlock.gif};
InBlock.gif
InBlock.gif //程序
InBlock.gif class ApplicationsTab : public QWidget
InBlock.gif{
InBlock.gif        Q_OBJECT
InBlock.gif
InBlock.gif public:
InBlock.gif        ApplicationsTab( const QFileInfo &fileInfo, QWidget *parent = 0);    
InBlock.gif};
InBlock.gif    
InBlock.gif //自定义Tab对话框
InBlock.gif class TabDialog: public QDialog
InBlock.gif{
InBlock.gif public:
InBlock.gif  TabDialog( const QString &fileName, QWidget *parent = 0);    
InBlock.gif private:
InBlock.gif  QTabWidget *tabWidget;
InBlock.gif  QDialogButtonBox *buttonBox;
InBlock.gif};
InBlock.gif
InBlock.gif
InBlock.gif#endif // __TABDLG_H__
 
tabdlg.cpp:
 
InBlock.gif#include <QTabWidget>
InBlock.gif#include <QWidget>
InBlock.gif#include <QDialog>
InBlock.gif#include <QFileInfo>
InBlock.gif#include <QVBoxLayout>
InBlock.gif#include <QDialogButtonBox>
InBlock.gif#include <QLabel>
InBlock.gif#include <QLineEdit>
InBlock.gif#include <QDateTime>
InBlock.gif#include <QGroupBox>
InBlock.gif#include <QCheckBox>
InBlock.gif#include <QListWidget>
InBlock.gif
InBlock.gif#include "tabdlg.h"
InBlock.gif
InBlock.gifTabDialog::TabDialog( const QString &fileName, QWidget *parent):QDialog(parent)
InBlock.gif{
InBlock.gif  QFileInfo fileInfo(fileName);
InBlock.gif    
InBlock.gif  tabWidget= new QTabWidget;
InBlock.gif  tabWidget->addTab( new GeneralTab(fileName),trUtf8( "常规"));
InBlock.gif  tabWidget->addTab( new PermissionsTab(fileName),trUtf8( "权限"));
InBlock.gif  tabWidget->addTab( new ApplicationsTab(fileName),trUtf8( "应用程序"));
InBlock.gif    
InBlock.gif  buttonBox= new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
InBlock.gif    
InBlock.gif  connect(buttonBox,SIGNAL(accepted()), this,SLOT(accept())); //OK
InBlock.gif  connect(buttonBox,SIGNAL(rejected()), this,SLOT(reject())); //Cancel
InBlock.gif    
InBlock.gif  QVBoxLayout *mainLayout= new QVBoxLayout;
InBlock.gif  mainLayout->addWidget(tabWidget);
InBlock.gif  mainLayout->addWidget(buttonBox);
InBlock.gif    
InBlock.gif  setLayout(mainLayout);
InBlock.gif    
InBlock.gif  setWindowTitle(trUtf8( "Tab对话框"));
InBlock.gif}
InBlock.gif    
InBlock.gif //常规面板类构造函数实现    
InBlock.gifGeneralTab::GeneralTab( const QFileInfo &fileInfo, QWidget *parent)
InBlock.gif  :QWidget(parent)
InBlock.gif{
InBlock.gif         QLabel *fileNameLabel = new QLabel(trUtf8( "文件名:"));
InBlock.gif         QLineEdit *fileNameEdit = new QLineEdit(fileInfo.fileName()); //去掉目录路径前缀后的
InBlock.gif
InBlock.gif         QLabel *pathLabel = new QLabel(trUtf8( "路径:"));
InBlock.gif         QLabel *pathValueLabel = new QLabel(fileInfo.absoluteFilePath()); //完整的路径名
InBlock.gif         pathValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); //设置label的样式
InBlock.gif
InBlock.gif         QLabel *sizeLabel = new QLabel(trUtf8( "大小:"));
InBlock.gif         qlonglong size = fileInfo.size()/1024; //size()返回字节大小
InBlock.gif         QLabel *sizeValueLabel = new QLabel(trUtf8( "%1 K").arg(size));
InBlock.gif         sizeValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
InBlock.gif
InBlock.gif         QLabel *lastReadLabel = new QLabel(trUtf8( "上次读取时间:"));
InBlock.gif         QLabel *lastReadValueLabel = new QLabel(fileInfo.lastRead().toString());
InBlock.gif         lastReadValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
InBlock.gif
InBlock.gif         QLabel *lastModLabel = new QLabel(trUtf8( "上次修改时间:"));
InBlock.gif         QLabel *lastModValueLabel = new QLabel(fileInfo.lastModified().toString());
InBlock.gif         lastModValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
InBlock.gif
InBlock.gif         QVBoxLayout *mainLayout = new QVBoxLayout;
InBlock.gif         mainLayout->addWidget(fileNameLabel);
InBlock.gif         mainLayout->addWidget(fileNameEdit);
InBlock.gif         mainLayout->addWidget(pathLabel);
InBlock.gif         mainLayout->addWidget(pathValueLabel);
InBlock.gif         mainLayout->addWidget(sizeLabel);
InBlock.gif         mainLayout->addWidget(sizeValueLabel);
InBlock.gif         mainLayout->addWidget(lastReadLabel);
InBlock.gif         mainLayout->addWidget(lastReadValueLabel);
InBlock.gif         mainLayout->addWidget(lastModLabel);
InBlock.gif         mainLayout->addWidget(lastModValueLabel);
InBlock.gif         //mainLayout->addStretch(1);
InBlock.gif         setLayout(mainLayout);    
InBlock.gif}
InBlock.gif
InBlock.gif //权限面板类
InBlock.gifPermissionsTab::PermissionsTab( const QFileInfo &fileInfo, QWidget *parent)
InBlock.gif  :QWidget(parent)
InBlock.gif{
InBlock.gif     //群组框
InBlock.gif         QGroupBox *permissionsGroup = new QGroupBox(trUtf8( "权限"));
InBlock.gif
InBlock.gif         QCheckBox *readable = new QCheckBox(trUtf8( "可读"));
InBlock.gif         if (fileInfo.isReadable())
InBlock.gif                 readable->setChecked( true); //勾选
InBlock.gif
InBlock.gif         QCheckBox *writable = new QCheckBox(trUtf8( "可写"));
InBlock.gif         if ( fileInfo.isWritable() )
InBlock.gif                 writable->setChecked( true);
InBlock.gif
InBlock.gif         QCheckBox *executable = new QCheckBox(trUtf8( "可执行"));
InBlock.gif         if ( fileInfo.isExecutable() )
InBlock.gif                 executable->setChecked( true);
InBlock.gif
InBlock.gif         QGroupBox *ownerGroup = new QGroupBox(trUtf8( "所有权"));
InBlock.gif
InBlock.gif         QLabel *ownerLabel = new QLabel(trUtf8( "所有者"));
InBlock.gif         QLabel *ownerValueLabel = new QLabel(fileInfo.owner());
InBlock.gif         ownerValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
InBlock.gif
InBlock.gif         QLabel *groupLabel = new QLabel(trUtf8( "组"));
InBlock.gif         QLabel *groupValueLabel = new QLabel(fileInfo.group());
InBlock.gif         groupValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
InBlock.gif
InBlock.gif         QVBoxLayout *permissionsLayout = new QVBoxLayout;
InBlock.gif         permissionsLayout->addWidget(readable);
InBlock.gif         permissionsLayout->addWidget(writable);
InBlock.gif         permissionsLayout->addWidget(executable);
InBlock.gif         permissionsGroup->setLayout(permissionsLayout); //权限组
InBlock.gif
InBlock.gif         QVBoxLayout *ownerLayout = new QVBoxLayout;
InBlock.gif         ownerLayout->addWidget(ownerLabel);
InBlock.gif         ownerLayout->addWidget(ownerValueLabel);
InBlock.gif         ownerLayout->addWidget(groupLabel);
InBlock.gif         ownerLayout->addWidget(groupValueLabel);
InBlock.gif         ownerGroup->setLayout(ownerLayout); //所有权组
InBlock.gif
InBlock.gif         QVBoxLayout *mainLayout = new QVBoxLayout;
InBlock.gif         mainLayout->addWidget(permissionsGroup);
InBlock.gif         mainLayout->addWidget(ownerGroup);
InBlock.gif         //mainLayout->addStretch(1);
InBlock.gif         setLayout(mainLayout);    
InBlock.gif}
InBlock.gif
InBlock.gif //应用程序选项卡类构造函数实现
InBlock.gifApplicationsTab::ApplicationsTab( const QFileInfo &fileInfo, QWidget *parent)
InBlock.gif  :QWidget(parent)
InBlock.gif{
InBlock.gif         QLabel *topLabel = new QLabel(trUtf8( "打开方式...:"));
InBlock.gif
InBlock.gif         QListWidget *applicationsListBox = new QListWidget;
InBlock.gif         QStringList applications;
InBlock.gif
InBlock.gif         for ( int i = 1; i <= 30; ++i)
InBlock.gif                 applications.append(trUtf8( "应用程序 %1").arg(i));
InBlock.gif         applicationsListBox->insertItems(0, applications);
InBlock.gif
InBlock.gif         QCheckBox *alwaysCheckBox;
InBlock.gif
InBlock.gif         if (fileInfo.suffix().isEmpty())
InBlock.gif                 alwaysCheckBox = new QCheckBox(trUtf8( "始终使用该程序"
InBlock.gif                         "打开该类型的文件"));
InBlock.gif         else
InBlock.gif                 alwaysCheckBox = new QCheckBox(trUtf8( "始终使用该程序"
InBlock.gif                         "打开此扩展名文件 '%1'").arg(fileInfo.suffix()));
InBlock.gif
InBlock.gif         QVBoxLayout *layout = new QVBoxLayout;
InBlock.gif         layout->addWidget(topLabel);
InBlock.gif         layout->addWidget(applicationsListBox);
InBlock.gif         layout->addWidget(alwaysCheckBox);
InBlock.gif         setLayout(layout);
InBlock.gif}
 
tabmain.cpp:
 
InBlock.gif#include <QApplication>
InBlock.gif#include "tabdlg.h"
InBlock.gif
InBlock.gif int main( int argc, char* argv[])
InBlock.gif{
InBlock.gif  QApplication app(argc,argv);
InBlock.gif  TabDialog tabdlg( "./src/tabmain.cpp");
InBlock.gif  tabdlg.show();
InBlock.gif   return app.exec();
InBlock.gif}
 
 
截图: