qsettings

How to save selected Items to Qsettings from QListWidget, QTableWidget

寵の児 提交于 2019-12-01 10:26:44
问题 I am Using PyQt5 and Py3.7, I am trying to loop through all my Qlistwidgets and save their string data, but also save all selected items on that widget. I slightly modified the loop from here, but am having some trouble getting the selected items to save and restore using the listwidget array loop. I checked the docs but can't seem to understand how to add additional options into the array (such as save all selected items), from the Qt docs for SetArrayIndex, here. My listWidgets have

QSettings::IniFormat values with “,” returned as QStringList

旧时模样 提交于 2019-11-29 12:30:24
I am using QSettings to parse an ini file: QSettings cfg(path, QSettings::IniFormat); When I obtain a value QVariant qv = cfg.value("title"); containing a comma the variant contains a QStringList instead of a QString title=foo => QString title=foo,bar => QStringList How can I always get strings, or at least obtain the original line ( title=foo,bar ) ? You have at least two ways to address this issue, all of them presented below: test.ini title="foo,bar" title_unquoted=foo,bar main.cpp #include <QSettings> #include <QDebug> int main() { QSettings settings("test.ini", QSettings::IniFormat); //

QSettings - File chooser should remember the last directory

耗尽温柔 提交于 2019-11-29 00:13:16
I upload a file from a location, then the next upload has to point the last uploaded location. How can I accomplish thus using QSettings ? Jérôme Before using QSettings , I would suggest, in your main() to set a few informations about your application and your company, informations that QSettings will be using : int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setApplicationName("test"); a.setOrganizationName("myorg"); a.setOrganizationDomain("myorg.com"); // etc... return a.exec(); } Then, when selecting a file with QFile::getOpenFileName() (for instance), you can read from a

Writing and reading custom class to QSettings

蓝咒 提交于 2019-11-28 23:34:56
I need to store instances of a custom class in the registry via QSettings. After reading from Qt's documentation, I think I have implemented the needed functions but I don't manage to save anything. Here's my custom class : class SRSDefinition{ public: SRSDefinition(QString name, QString definition) : qsName(name), qsDefinition(definition) { qRegisterMetaType<SRSDefinition>("SRSDefinition"); qRegisterMetaTypeStreamOperators<SRSDefinition>("SRSDefinition"); } SRSDefinition(const SRSDefinition& original) : qsName(original.qsName), qsDefinition(original.qsDefinition) {} SRSDefinition() : qsName("

QSettings::IniFormat values with “,” returned as QStringList

最后都变了- 提交于 2019-11-28 06:11:03
问题 I am using QSettings to parse an ini file: QSettings cfg(path, QSettings::IniFormat); When I obtain a value QVariant qv = cfg.value("title"); containing a comma the variant contains a QStringList instead of a QString title=foo => QString title=foo,bar => QStringList How can I always get strings, or at least obtain the original line ( title=foo,bar ) ? 回答1: You have at least two ways to address this issue, all of them presented below: test.ini title="foo,bar" title_unquoted=foo,bar main.cpp

How to save text in QLineEdits in PyQt even if the Widget gets closed?

依然范特西╮ 提交于 2019-11-28 01:40:49
Hello I have made a GUI for my script using PyQt I have a couple of Line edit ands a couple of buttons (.....) = (self.(.....).text()) which I use that text for my script as a variable (but I don't think thats important to the question) I want to be able to type text into the QLineEdits and for it to save so next time I open it the text will still be there I use PyQt5 then I use Py-installer to make it into an app So I want to be able to save the text inside the QLineEdits and then when It closes for it be be saved there for next time I open it> Ps. I am sharing this app with other people So I

QSettings - File chooser should remember the last directory

陌路散爱 提交于 2019-11-27 21:29:01
问题 I upload a file from a location, then the next upload has to point the last uploaded location. How can I accomplish thus using QSettings ? 回答1: Before using QSettings , I would suggest, in your main() to set a few informations about your application and your company, informations that QSettings will be using : int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setApplicationName("test"); a.setOrganizationName("myorg"); a.setOrganizationDomain("myorg.com"); // etc... return a

Writing and reading custom class to QSettings

心不动则不痛 提交于 2019-11-27 14:53:16
问题 I need to store instances of a custom class in the registry via QSettings. After reading from Qt's documentation, I think I have implemented the needed functions but I don't manage to save anything. Here's my custom class : class SRSDefinition{ public: SRSDefinition(QString name, QString definition) : qsName(name), qsDefinition(definition) { qRegisterMetaType<SRSDefinition>("SRSDefinition"); qRegisterMetaTypeStreamOperators<SRSDefinition>("SRSDefinition"); } SRSDefinition(const SRSDefinition&

How to save text in QLineEdits in PyQt even if the Widget gets closed?

半腔热情 提交于 2019-11-26 21:58:10
问题 Hello I have made a GUI for my script using PyQt I have a couple of Line edit ands a couple of buttons (.....) = (self.(.....).text()) which I use that text for my script as a variable (but I don't think thats important to the question) I want to be able to type text into the QLineEdits and for it to save so next time I open it the text will still be there I use PyQt5 then I use Py-installer to make it into an app So I want to be able to save the text inside the QLineEdits and then when It