These are chat archives for PySide/pyside2

4th
Jul 2017
Jose Molina
@votaguz
Jul 04 2017 14:15
Hi guys, anybody know how to add a tooltip to the selected option in a QComboBox ? I already managed to add tooltips to all elements in the QComboBox list, but after an element from the list is selected i can't make it to display the tooltip
From IRC (bridge bot)
@FromIRC
Jul 04 2017 15:41
<oprypin> @votaguz, would that mean adding the tooltip to the box itself?
Jose Molina
@votaguz
Jul 04 2017 15:46
After item is selected. I already managed how to do it, just detect the selection event and call setTooltip over the widget :) :)
From IRC (bridge bot)
@FromIRC
Jul 04 2017 15:46
<oprypin> yeah that's what i meant
Jose Molina
@votaguz
Jul 04 2017 18:41
Thanks anyways :)
Hi again, now i'm looking for some example code about how to save the state of open file dialog and restore it in a session in the future. Documentation says that i need to use a QSettings object, but i can't find any example of that
Typically this is used in conjunction with QSettings to remember the size for a future session.
But i don't fully understand how to use that QSettings class with those methods
Any guess ?
Thanks
From IRC (bridge bot)
@FromIRC
Jul 04 2017 18:47
<oprypin> @votaguz, *State methods convert the state to/from a bytestring. it is your job then to save and read the bytestrings somewhere. what would your preference be? a file in a current directory? some cross-platform yet platform-specific way in the user's folder?
Jose Molina
@votaguz
Jul 04 2017 18:47
Well the idea is save the last directory used in "Open File" dialog
From IRC (bridge bot)
@FromIRC
Jul 04 2017 18:48
<oprypin> i get it. save where?
Jose Molina
@votaguz
Jul 04 2017 18:48
Well i think maybe save it in "/home/" ?
Or something like that ?
From IRC (bridge bot)
@FromIRC
Jul 04 2017 18:49
<oprypin> ok so use QSettings to save it
Jose Molina
@votaguz
Jul 04 2017 18:50
Can you please show me how ? I mean some example code or something like that?
<oprypin> or if you wanna roll storage in your own file, you convert the bytes to base64 https://github.com/oprypin/sixcells/search?q=geometry
Jose Molina
@votaguz
Jul 04 2017 18:56
@oprypin thank you, but i still don't fully understand i mean, i must create the QSettings object
''' my_settings = QSettings( dialog.saveState() ) """
and then restore the settings like this ?
Jose Molina
@votaguz
Jul 04 2017 19:00
dialog.setCurrentDir( dialog.restoreState() ) ?
From IRC (bridge bot)
@FromIRC
Jul 04 2017 19:01
<oprypin> no
<oprypin> dialog.restoreState(settings.value("open_dialog_state"))
Jose Molina
@votaguz
Jul 04 2017 19:03
Seems like restore state it's redundant to me, i mean why just don't call settings.value and use the attribute for that value ?
Seems like i'm missing something right ? :smile: