diff --git a/src/importexport/musicxml/internal/musicxml/exportxml.cpp b/src/importexport/musicxml/internal/musicxml/exportxml.cpp index 368e18a40f9f5..1576d529c7a73 100644 --- a/src/importexport/musicxml/internal/musicxml/exportxml.cpp +++ b/src/importexport/musicxml/internal/musicxml/exportxml.cpp @@ -6750,7 +6750,11 @@ void ExportMusicXml::findAndExportClef(const Measure* const m, const int staves, if ((tick.isZero() || !cle->generated()) && ((seg->measure() != m) || ((seg->segmentType() == SegmentType::HeaderClef) && !cle->otherClef()))) { clefDebug("exportxml: clef exported"); - clef(sstaff, cle->clefType(), color2xml(cle)); + QString clefAttr = color2xml(cle); + if (!cle->visible()) { + clefAttr += " print-object=\"no\""; + } + clef(sstaff, cle->clefType(), clefAttr); } else { clefDebug("exportxml: clef not exported"); } @@ -6980,13 +6984,14 @@ void ExportMusicXml::writeElement(EngravingItem* el, const Measure* m, staff_idx // these will be output at the start of the next measure const auto cle = toClef(el); const auto ti = cle->segment()->tick(); + const QString visible = (!cle->visible()) ? " print-object=\"no\"" : ""; clefDebug("exportxml: clef in measure ti=%d ct=%d gen=%d", ti, int(cle->clefType()), el->generated()); if (el->generated()) { clefDebug("exportxml: generated clef not exported"); } else if (!el->generated() && tickIsInMiddleOfMeasure(ti, m)) { - clef(sstaff, cle->clefType(), color2xml(cle)); + clef(sstaff, cle->clefType(), color2xml(cle) + visible); } else if (!el->generated() && (ti == m->tick()) && (cle->segment()->segmentType() != SegmentType::HeaderClef)) { - clef(sstaff, cle->clefType(), color2xml(cle) + QString(" after-barline=\"yes\"")); + clef(sstaff, cle->clefType(), color2xml(cle) + visible + QString(" after-barline=\"yes\"")); } else { clefDebug("exportxml: clef not exported"); } diff --git a/src/importexport/musicxml/internal/musicxml/importmxmlpass2.cpp b/src/importexport/musicxml/internal/musicxml/importmxmlpass2.cpp index 3da2c3f204077..5a477aef46662 100644 --- a/src/importexport/musicxml/internal/musicxml/importmxmlpass2.cpp +++ b/src/importexport/musicxml/internal/musicxml/importmxmlpass2.cpp @@ -3947,8 +3947,9 @@ void MusicXMLParserPass2::clef(const QString& partId, Measure* measure, const Fr int i = 0; int line = -1; - QString strClefno = _e.attributes().value("number").toString(); + const QString strClefno = _e.attributes().value("number").toString(); const bool afterBarline = _e.attributes().value("after-barline") == "yes"; + const bool printObject = _e.attributes().value("print-object") != "no"; while (_e.readNextStartElement()) { if (_e.name() == "sign") { @@ -4059,6 +4060,7 @@ void MusicXMLParserPass2::clef(const QString& partId, Measure* measure, const Fr Clef* clefs = Factory::createClef(s); clefs->setClefType(clef); + clefs->setVisible(printObject); track_idx_t track = _pass1.trackForPart(partId) + clefno * VOICES; clefs->setTrack(track); s->add(clefs); diff --git a/src/importexport/musicxml/tests/data/testInvisibleElements.xml b/src/importexport/musicxml/tests/data/testInvisibleElements.xml index ffe9266836b59..67c83362594c3 100644 --- a/src/importexport/musicxml/tests/data/testInvisibleElements.xml +++ b/src/importexport/musicxml/tests/data/testInvisibleElements.xml @@ -43,7 +43,7 @@ 4 4 - + G 2