shortcut to show / hide the layers as per the sequence Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Toggling selected feature when using Node Tool of QGIS?In qgis2threejs html output select deselect the layers not workingImages in my Click Info box are not appearing in both published CartoDB layersWhen editing layer, cannot save edits for lines or polygonsOrder of WMS layers is reversed in QGIS?Add dummy layer so that layer with “soft light” blending mode is visible by itselfUsing Select by Attribute with multiple layers in ArcGIS Pro?Allowing all QGIS workspace layers to be editable at onceHow to rename duplicated layers in QGIS3?
Sally's older brother
How can I list files in reverse time order by a command and pass them as arguments to another command?
How could a hydrazine and N2O4 cloud (or it's reactants) show up in weather radar?
Can gravitational waves pass through a black hole?
Inverse square law not accurate for non-point masses?
Diophantine equation 3^a+1=3^b+5^c
newbie Q : How to read an output file in one command line
Does the main washing effect of soap come from foam?
Random body shuffle every night—can we still function?
Any stored/leased 737s that could substitute for grounded MAXs?
Should man-made satellites feature an intelligent inverted "cow catcher"?
New Order #6: Easter Egg
Did any compiler fully use 80-bit floating point?
Centre cell vertically in tabularx
Is a copyright notice with a non-existent name be invalid?
Does the transliteration of 'Dravidian' exist in Hindu scripture? Does 'Dravida' refer to a Geographical area or an ethnic group?
How does the body cool itself in a stillsuit?
How do you write "wild blueberries flavored"?
How to make an animal which can only breed for a certain number of generations?
Pointing to problems without suggesting solutions
Did pre-Columbian Americans know the spherical shape of the Earth?
Why is there so little support for joining EFTA in the British parliament?
Statistical analysis applied to methods coming out of Machine Learning
Why can't fire hurt Daenerys but it did to Jon Snow in season 1?
shortcut to show / hide the layers as per the sequence
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Toggling selected feature when using Node Tool of QGIS?In qgis2threejs html output select deselect the layers not workingImages in my Click Info box are not appearing in both published CartoDB layersWhen editing layer, cannot save edits for lines or polygonsOrder of WMS layers is reversed in QGIS?Add dummy layer so that layer with “soft light” blending mode is visible by itselfUsing Select by Attribute with multiple layers in ArcGIS Pro?Allowing all QGIS workspace layers to be editable at onceHow to rename duplicated layers in QGIS3?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Does anyone know any shortcut to display / hide the layers as per the order? For example, F1 displays and hides layer 1, F2 displays and hides layer 2.
I found the shortcut to hide all the layers and hide the selected layer, but for what I want it does not work, because I need to edit layer 1 (shp) and toggle between displaying and hiding layer 2 (raster).
QGIS 2.18
qgis layers editing
add a comment |
Does anyone know any shortcut to display / hide the layers as per the order? For example, F1 displays and hides layer 1, F2 displays and hides layer 2.
I found the shortcut to hide all the layers and hide the selected layer, but for what I want it does not work, because I need to edit layer 1 (shp) and toggle between displaying and hiding layer 2 (raster).
QGIS 2.18
qgis layers editing
add a comment |
Does anyone know any shortcut to display / hide the layers as per the order? For example, F1 displays and hides layer 1, F2 displays and hides layer 2.
I found the shortcut to hide all the layers and hide the selected layer, but for what I want it does not work, because I need to edit layer 1 (shp) and toggle between displaying and hiding layer 2 (raster).
QGIS 2.18
qgis layers editing
Does anyone know any shortcut to display / hide the layers as per the order? For example, F1 displays and hides layer 1, F2 displays and hides layer 2.
I found the shortcut to hide all the layers and hide the selected layer, but for what I want it does not work, because I need to edit layer 1 (shp) and toggle between displaying and hiding layer 2 (raster).
QGIS 2.18
qgis layers editing
qgis layers editing
asked May 11 '18 at 14:53
hugonbghugonbg
347113
347113
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Not exactly what you're asking for but close. The following code when run from the QGIS 2.x Python console (tested on 2.16.0) will let you to choose a layer then toggle its visibility.
Selecting a layer then pressing
Alt Z
will choose it for toggling.Pressing
Z
will toggle the chosen layer's visibility regardless of which layer is currently active.
Here's the code:
from PyQt4.QtGui import QShortcut, QKeySequence
from PyQt4.QtCore import Qt
root = QgsProject.instance().layerTreeRoot()
currentToggleNode = root.findLayer(iface.activeLayer().id())
def setToggleLayer():
currentToggleNode = root.findLayer(iface.activeLayer().id())
def toggleLayer():
new_state = Qt.Checked if currentToggleNode.isVisible() == Qt.Unchecked else Qt.Unchecked
currentToggleNode.setVisible(new_state)
shortcutSetToggleLayer = QShortcut(QKeySequence(Qt.AltModifier + Qt.Key_Z), iface.mainWindow())
shortcutSetToggleLayer.setContext(Qt.ApplicationShortcut)
shortcutSetToggleLayer.activated.connect(setToggleLayer)
shortcutToggleLayer = QShortcut(QKeySequence(Qt.Key_Z), iface.mainWindow())
shortcutToggleLayer.setContext(Qt.ApplicationShortcut)
shortcutToggleLayer.activated.connect(toggleLayer)
You'll need to run the above code from the Python console once each time you start QGIS (you can save it in a script file to avoid retyping; see the QGIS docs for details). If you get any error messages you'll need to restart QGIS before fixing the problematic code since Python state is pretty persistent within a QGIS session.
Known bugs:
- Will probably break if toggling (
Z
) is used before a toggle layer has been selected (withAlt Z
)
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f282590%2fshortcut-to-show-hide-the-layers-as-per-the-sequence%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Not exactly what you're asking for but close. The following code when run from the QGIS 2.x Python console (tested on 2.16.0) will let you to choose a layer then toggle its visibility.
Selecting a layer then pressing
Alt Z
will choose it for toggling.Pressing
Z
will toggle the chosen layer's visibility regardless of which layer is currently active.
Here's the code:
from PyQt4.QtGui import QShortcut, QKeySequence
from PyQt4.QtCore import Qt
root = QgsProject.instance().layerTreeRoot()
currentToggleNode = root.findLayer(iface.activeLayer().id())
def setToggleLayer():
currentToggleNode = root.findLayer(iface.activeLayer().id())
def toggleLayer():
new_state = Qt.Checked if currentToggleNode.isVisible() == Qt.Unchecked else Qt.Unchecked
currentToggleNode.setVisible(new_state)
shortcutSetToggleLayer = QShortcut(QKeySequence(Qt.AltModifier + Qt.Key_Z), iface.mainWindow())
shortcutSetToggleLayer.setContext(Qt.ApplicationShortcut)
shortcutSetToggleLayer.activated.connect(setToggleLayer)
shortcutToggleLayer = QShortcut(QKeySequence(Qt.Key_Z), iface.mainWindow())
shortcutToggleLayer.setContext(Qt.ApplicationShortcut)
shortcutToggleLayer.activated.connect(toggleLayer)
You'll need to run the above code from the Python console once each time you start QGIS (you can save it in a script file to avoid retyping; see the QGIS docs for details). If you get any error messages you'll need to restart QGIS before fixing the problematic code since Python state is pretty persistent within a QGIS session.
Known bugs:
- Will probably break if toggling (
Z
) is used before a toggle layer has been selected (withAlt Z
)
add a comment |
Not exactly what you're asking for but close. The following code when run from the QGIS 2.x Python console (tested on 2.16.0) will let you to choose a layer then toggle its visibility.
Selecting a layer then pressing
Alt Z
will choose it for toggling.Pressing
Z
will toggle the chosen layer's visibility regardless of which layer is currently active.
Here's the code:
from PyQt4.QtGui import QShortcut, QKeySequence
from PyQt4.QtCore import Qt
root = QgsProject.instance().layerTreeRoot()
currentToggleNode = root.findLayer(iface.activeLayer().id())
def setToggleLayer():
currentToggleNode = root.findLayer(iface.activeLayer().id())
def toggleLayer():
new_state = Qt.Checked if currentToggleNode.isVisible() == Qt.Unchecked else Qt.Unchecked
currentToggleNode.setVisible(new_state)
shortcutSetToggleLayer = QShortcut(QKeySequence(Qt.AltModifier + Qt.Key_Z), iface.mainWindow())
shortcutSetToggleLayer.setContext(Qt.ApplicationShortcut)
shortcutSetToggleLayer.activated.connect(setToggleLayer)
shortcutToggleLayer = QShortcut(QKeySequence(Qt.Key_Z), iface.mainWindow())
shortcutToggleLayer.setContext(Qt.ApplicationShortcut)
shortcutToggleLayer.activated.connect(toggleLayer)
You'll need to run the above code from the Python console once each time you start QGIS (you can save it in a script file to avoid retyping; see the QGIS docs for details). If you get any error messages you'll need to restart QGIS before fixing the problematic code since Python state is pretty persistent within a QGIS session.
Known bugs:
- Will probably break if toggling (
Z
) is used before a toggle layer has been selected (withAlt Z
)
add a comment |
Not exactly what you're asking for but close. The following code when run from the QGIS 2.x Python console (tested on 2.16.0) will let you to choose a layer then toggle its visibility.
Selecting a layer then pressing
Alt Z
will choose it for toggling.Pressing
Z
will toggle the chosen layer's visibility regardless of which layer is currently active.
Here's the code:
from PyQt4.QtGui import QShortcut, QKeySequence
from PyQt4.QtCore import Qt
root = QgsProject.instance().layerTreeRoot()
currentToggleNode = root.findLayer(iface.activeLayer().id())
def setToggleLayer():
currentToggleNode = root.findLayer(iface.activeLayer().id())
def toggleLayer():
new_state = Qt.Checked if currentToggleNode.isVisible() == Qt.Unchecked else Qt.Unchecked
currentToggleNode.setVisible(new_state)
shortcutSetToggleLayer = QShortcut(QKeySequence(Qt.AltModifier + Qt.Key_Z), iface.mainWindow())
shortcutSetToggleLayer.setContext(Qt.ApplicationShortcut)
shortcutSetToggleLayer.activated.connect(setToggleLayer)
shortcutToggleLayer = QShortcut(QKeySequence(Qt.Key_Z), iface.mainWindow())
shortcutToggleLayer.setContext(Qt.ApplicationShortcut)
shortcutToggleLayer.activated.connect(toggleLayer)
You'll need to run the above code from the Python console once each time you start QGIS (you can save it in a script file to avoid retyping; see the QGIS docs for details). If you get any error messages you'll need to restart QGIS before fixing the problematic code since Python state is pretty persistent within a QGIS session.
Known bugs:
- Will probably break if toggling (
Z
) is used before a toggle layer has been selected (withAlt Z
)
Not exactly what you're asking for but close. The following code when run from the QGIS 2.x Python console (tested on 2.16.0) will let you to choose a layer then toggle its visibility.
Selecting a layer then pressing
Alt Z
will choose it for toggling.Pressing
Z
will toggle the chosen layer's visibility regardless of which layer is currently active.
Here's the code:
from PyQt4.QtGui import QShortcut, QKeySequence
from PyQt4.QtCore import Qt
root = QgsProject.instance().layerTreeRoot()
currentToggleNode = root.findLayer(iface.activeLayer().id())
def setToggleLayer():
currentToggleNode = root.findLayer(iface.activeLayer().id())
def toggleLayer():
new_state = Qt.Checked if currentToggleNode.isVisible() == Qt.Unchecked else Qt.Unchecked
currentToggleNode.setVisible(new_state)
shortcutSetToggleLayer = QShortcut(QKeySequence(Qt.AltModifier + Qt.Key_Z), iface.mainWindow())
shortcutSetToggleLayer.setContext(Qt.ApplicationShortcut)
shortcutSetToggleLayer.activated.connect(setToggleLayer)
shortcutToggleLayer = QShortcut(QKeySequence(Qt.Key_Z), iface.mainWindow())
shortcutToggleLayer.setContext(Qt.ApplicationShortcut)
shortcutToggleLayer.activated.connect(toggleLayer)
You'll need to run the above code from the Python console once each time you start QGIS (you can save it in a script file to avoid retyping; see the QGIS docs for details). If you get any error messages you'll need to restart QGIS before fixing the problematic code since Python state is pretty persistent within a QGIS session.
Known bugs:
- Will probably break if toggling (
Z
) is used before a toggle layer has been selected (withAlt Z
)
answered Nov 9 '18 at 21:12
Alex HajnalAlex Hajnal
529210
529210
add a comment |
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f282590%2fshortcut-to-show-hide-the-layers-as-per-the-sequence%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown