当前位置: 代码迷 >> QT开发 >> 有关与布局管理的有关问题,出有关问题了
  详细解决方案

有关与布局管理的有关问题,出有关问题了

热度:113   发布时间:2016-04-25 04:56:12.0
有关与布局管理的问题,出问题了
部分代码如下
C/C++ code
//mywnd类的头文件class mywnd : public QWidget{    Q_OBJECTprivate:    QLabel *NameLabel;    QLabel *SexLabel;    QLabel *TelLabel;    QLabel *EmailLabel;    QLabel *BirthdayLabel;    QLabel *AddrLabel;    QLabel *AttachLabel;    QLineEdit *NameEdit;    QComboBox *SexBox;    QLineEdit *TelEdit;    QLineEdit *EmailEdit;    QDateEdit *BirthdayEdit;    QLineEdit *AddrEdit;    QLineEdit *AttachEdit;    QPushButton *OpenButton;    QPushButton *AddButton;    QPushButton *RemoveButton;    QPushButton *QuitButton;    QPushButton *SaveButton;    QPushButton *SaveAsButton;    QPushButton *CleanButton;    QPushButton *CloseButton;    QPushButton *NewButton;    QStatusBar *Information;    datatable *MyTable;    QFile MyFile;    QDataStream MyStream;    QMap<QString,info> NewData;    bool IsSaved;    QApplication *MyApp;private slots:    void add();    void remove();    void openfile();    void save();    void quit();    void clean();    void closefile();    void saveas();    void newfile();signals:    void datachanged(QMap<QString,info> *);public:    mywnd(QApplication *);};

C/C++ code
//mywnd类的构造函数mywnd::mywnd(QApplication *a){    setWindowTitle(tr("Contact"));    MyApp=a;    IsSaved=true;    NameLabel=new QLabel(tr("&Name"));    SexLabel=new QLabel(tr("&Sex"));    TelLabel=new QLabel(tr("&Telephone Number"));    EmailLabel=new QLabel(tr("&E-mail Address"));    BirthdayLabel=new QLabel(tr("&Birthyday"));    AddrLabel=new QLabel(tr("&Address"));    AttachLabel=new QLabel(tr("Atta&chment"));    NameEdit=new QLineEdit;    TelEdit=new QLineEdit;    SexBox=new QComboBox;    SexBox->addItem(tr("male"));    SexBox->addItem(tr("female"));    EmailEdit=new QLineEdit;    AddrEdit=new QLineEdit;    AttachEdit=new QLineEdit;    BirthdayEdit=new QDateEdit;    BirthdayEdit->setDisplayFormat(QString("MM.dd.yyyy"));    BirthdayEdit->setDate(QDate::currentDate());    AddButton=new QPushButton(tr("&Add"));    AddButton->setEnabled(false);    QuitButton=new QPushButton(tr("&Quit"));    RemoveButton=new QPushButton(tr("&Remove"));    RemoveButton->setEnabled(false);    NewButton=new QPushButton(tr("&New"));    OpenButton=new QPushButton(tr("&Open"));    OpenButton->setDefault(true);    SaveButton=new QPushButton(tr("&Save"));    SaveButton->setEnabled(false);    SaveAsButton=new QPushButton(tr("Sa&ve As"));    SaveAsButton->setEnabled(false);    CleanButton=new QPushButton(tr("C&lean"));    CloseButton=new QPushButton(tr("&Close"));    CloseButton->setEnabled(false);    NameLabel->setBuddy(NameEdit);    SexLabel->setBuddy(SexBox);    TelLabel->setBuddy(TelEdit);    EmailLabel->setBuddy(EmailEdit);    BirthdayLabel->setBuddy(BirthdayEdit);    AddrLabel->setBuddy(AddrEdit);    AttachLabel->setBuddy(AttachEdit);    Information=new QStatusBar(this);    MyTable=new datatable(this);    QFormLayout *UpLayout=new QFormLayout;    UpLayout->addRow(NameLabel,NameEdit);    UpLayout->addRow(TelLabel,TelEdit);    UpLayout->addRow(SexLabel,SexBox);    UpLayout->addRow(EmailLabel,EmailEdit);    UpLayout->addRow(BirthdayLabel,BirthdayEdit);    UpLayout->addRow(AddrLabel,AddrEdit);    UpLayout->addRow(AttachLabel,AttachEdit);    QHBoxLayout *DownLayout=new QHBoxLayout;    DownLayout->addWidget(OpenButton);    DownLayout->addWidget(NewButton);    DownLayout->addWidget(AddButton);    DownLayout->addWidget(RemoveButton);    DownLayout->addWidget(CleanButton);    DownLayout->addWidget(SaveButton);    DownLayout->addWidget(SaveAsButton);    DownLayout->addWidget(CloseButton);    DownLayout->addWidget(QuitButton);    QVBoxLayout *MainLayout=new QVBoxLayout;    MainLayout->addLayout(UpLayout);    MainLayout->addWidget(MyTable);    MainLayout->addLayout(DownLayout);    MainLayout->addWidget(Information);    setLayout(MainLayout);    setFixedHeight(sizeHint().height());    QObject::connect(QuitButton,SIGNAL(clicked()),this,SLOT(quit()));    QObject::connect(AddButton,SIGNAL(clicked()),this,SLOT(add()));    QObject::connect(RemoveButton,SIGNAL(clicked()),this,SLOT(remove()));    QObject::connect(OpenButton,SIGNAL(clicked()),this,SLOT(openfile()));    QObject::connect(SaveButton,SIGNAL(clicked()),this,SLOT(save()));    QObject::connect(CleanButton,SIGNAL(clicked()),this,SLOT(clean()));    QObject::connect(CloseButton,SIGNAL(clicked()),this,SLOT(closefile()));    QObject::connect(SaveAsButton,SIGNAL(clicked()),this,SLOT(saveas()));    QObject::connect(NewButton,SIGNAL(clicked()),this,SLOT(newfile()));    QObject::connect(this,SIGNAL(datachanged(QMap<QString,info> *)),MyTable,SLOT(update(QMap<QString,info> *)));}
  相关解决方案