From: Diane Trout Date: Tue, 3 Apr 2007 23:38:24 +0000 (+0000) Subject: delete default layout in MotifEditor X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=mussa.git;a=commitdiff_plain;h=4b9dd885cdfef6d73c82bae5f112a063588766a9;ds=sidebyside delete default layout in MotifEditor Qt was generating warning messages about couldn't set layout on the MotifEditor while one was already set. It turns out you need to delete the default layout before calling setLayout(). --- diff --git a/qui/motif_editor/MotifEditor.cpp b/qui/motif_editor/MotifEditor.cpp index acde2d3..fec73f7 100644 --- a/qui/motif_editor/MotifEditor.cpp +++ b/qui/motif_editor/MotifEditor.cpp @@ -21,17 +21,6 @@ MotifEditor::MotifEditor(MussaRef m, QWidget *parent) assert (m != 0); const set &motif = analysis->motifs(); vector motif_seq(motif.begin(), motif.end()); - - applyButton->setFocusPolicy(Qt::StrongFocus); - connect(applyButton, SIGNAL(clicked()), this, SLOT(updateAnalysisMotifs())); - button_layout->addStretch(); - button_layout->addWidget(applyButton); - - table->setItemDelegate(delegate); - - editor_layout->addWidget(table); - editor_layout->addLayout(button_layout); - setLayout(editor_layout); updateTitle(); updateModel(); @@ -39,11 +28,25 @@ MotifEditor::MotifEditor(MussaRef m, QWidget *parent) void MotifEditor::setupWidgets() { - editor_layout = new QVBoxLayout(this); - button_layout = new QHBoxLayout(this); - table = new QTableView(this); + editor_layout = new QVBoxLayout; + button_layout = new QHBoxLayout; + // remove default layout (very safely) + if (layout()) delete layout(); + + table = new QTableView; delegate = new MotifEditorDelegate(this); applyButton = new QPushButton("apply"); + + applyButton->setFocusPolicy(Qt::StrongFocus); + connect(applyButton, SIGNAL(clicked()), this, SLOT(updateAnalysisMotifs())); + button_layout->addStretch(); + button_layout->addWidget(applyButton); + + table->setItemDelegate(delegate); + + editor_layout->addWidget(table); + editor_layout->addLayout(button_layout); + setLayout(editor_layout); } void MotifEditor::updateModel()