Skip to content

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed
 

‎src/gui/qgisapp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,8 +1118,8 @@ void QgisApp::createOverview()
11181118
void QgisApp::createLegend()
11191119
{
11201120
//legend
1121-
//mMapLegend = new QgsLegend(this,NULL, "theMapLegend");
1122-
mMapLegend = new QgsLegend(this, this, "theMapLegend");
1121+
mMapLegend = new QgsLegend(this,NULL, "theMapLegend");
1122+
mMapLegend->setObjectName("theMapLegend");
11231123
mMapLegend->setMapCanvas(mMapCanvas);
11241124
QWhatsThis::add(mMapLegend, tr("Map legend that displays all the layers currently on the map canvas. Click on the check box to turn a layer on or off. Double click on a layer in the legend to customize its appearance and set other properties."));
11251125
QVBoxLayout *myLegendLayout = new QVBoxLayout;

‎src/gui/qgsproject.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ using namespace std;
3838
#include <QWidget>
3939
#include <QObject>
4040
#include <QTextStream>
41-
41+
#include <QToolBox>
42+
#include <QSplitter>
4243

4344

4445
static const char *const ident_ = "$Id$";
@@ -771,15 +772,16 @@ static QgsMapCanvas * _findMapCanvas(QString const &canonicalMapCanvasName)
771772
static QgsLegend * _findLegend()
772773
{
773774
QString canonicalLegendName = "theMapLegend";
774-
QgsLegend* theLegend = NULL;
775+
QgsLegend* theLegend = 0;
775776

776777
QWidgetList wlist = QApplication::topLevelWidgets();
777778
foreach (QWidget *widget, QApplication::topLevelWidgets())
778779
{
779-
//theLegend = dynamic_cast <QgsLegend *>(widget->child(canonicalLegendName.toLocal8Bit().data(), 0, true));
780-
theLegend = widget->findChild<QgsLegend*>("theMapLegend");
780+
theLegend = dynamic_cast <QgsLegend *>(widget->child(canonicalLegendName.toLocal8Bit().data(), 0, true));
781781
if(theLegend)
782-
break;
782+
{
783+
break;
784+
}
783785
}
784786

785787
return theLegend;

0 commit comments

Comments
 (0)
Please sign in to comment.