QProcess.start() is deprecated

Hi Martin,

The following code in your example is obsolete.

/concurrent/qprocess.py:83: DeprecationWarning: QProcess.start(const QString & command, QFlags<QIODevice::OpenModeFlag> mode) is deprecated
self.p.start("python dummy_script.py")

I have checked the documentation at Qt, it also said obsolete but did not suggest replacement. Do you have an updated code?

I am running PySide2 version and Python 3.7.6


Ah, interesting!

The .start() method is overloaded so there is another form where you call it without arguments (or optionally pass the OpenModeFlag flag). That one doesn’t look to be deprecated. To use this you will need to set the program and arguments separately using the specific methods –

p = QProcess()

Note that the arguments are passed as a list of strings.

I’ll update this in the book.


Thanks @martin. Just wondering where did you find the latest API from the documentation? I tried to search from Qt Documentation but couldn’t find anything useful. I guess Qt documentation wasn’t up to date then?

It’s there in the Qt5 documentation, just easy to miss. Since .start() is an overloaded method it has multiple entries in the page. The links at the top of the page point to two variants –

On that same page you can see the setProgram and setArguments methods, which accept the program and arguments in the same format as the first form of .start().

I missed that first method actually (assumed it was the old one that was deprecated). But it’s not, so it looks like you could also do the following –

p = QProcess()
p.start("python", ['dummy_script.py'])

…which is a bit closer to the original.

1 Like