LINUX.ORG.RU

Сообщения doomer

 

Как вызывать свежий питон в кьют вместо дефолтного кутэшного

Вызываю питон скрипт в консоли

...
        QProcessEnvironment env =QProcessEnvironment::systemEnvironment();
        env.insert("PYTHONHOME", "..\\Python\\Python312\\");
        env.insert("PYTHONPATH", "..\\Python\\Python312\\Lib\\site-packages");
        QProcess myProcess;
        myProcess.setProcessEnvironment(env);
        QString com = "..\\Python\\Python312\\python.exe main.py";
      if (myProcess.execute(com)!=0) {
        qDebug()<<"error";
...
    }
Выдает конфиг в консоль
 PYTHONHOME = '..\QT\Tools\mingw\bin\..\opt'
 PYTHONPATH = (not set)
 program name = '..\Python\Python312\python.exe'
 isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '..\QT\Tools\mingw\opt\Lib'
  sys._base_executable = '..\\Python\\Python312\\python.exe'
  sys.base_prefix = '..\\QT\\Tools\\mingw\\bin\\..\\opt'
  sys.base_exec_prefix = '..\\QT\\Tools\\mingw\\bin\\..\\opt'
  sys.platlibdir = 'DLLs'
  sys.executable = '..\\Python\\Python312\\python.exe'
  sys.prefix = '..\\QT\\Tools\\mingw\\bin\\..\\opt'
  sys.exec_prefix = '..\\QT\\Tools\\mingw\\bin\\..\\opt'
  sys.path = [
    '..\\Python\\Python312\\python312.zip',
    '..\\QT\\Tools\\mingw\\opt\\DLLs',
    '..\\QT\\Tools\\mingw\\opt\\Lib',
    '..\\Python\\Python312',
  ]
Выдает ошибку выполнения скрипта
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00001b70 (most recent call first):
  <no Python frame>
error
Видно что разные версии пайтона в конфиге - один берется из com строки, задал переменую пайтонхоум, но она почему то перезаписывается на кутэшный старый пайтон в котором ошибки из-за того что версия устаревшая и в скрипте на пайтоне используются библиотеки из нового пайтона

 , ,

doomer
()

Вываливается sigsegv Qmap

Читаю xml файл и при считывании первого тега - я его в Qmap пытаюсь записать вылетает sigsegv.

#ifndef IXMLREADER_H
#define IXMLREADER_H
#include <QFile>
#include <QDebug>
#include <QtXml>
#include <QMap>
class iXMLReader
{
    QMap<QString,QString> xml;
public:
    iXMLReader();
    void traverseNode(const QDomNode node);
    bool Validate();
};

#endif // IXMLREADER_H
//...
#include "ixmlreader.h"

iXMLReader::iXMLReader()
{

}
void iXMLReader::traverseNode(const QDomNode node)
{
    QDomNode  domNode  = node.firstChild();
    while(!domNode.isNull())
    {
        if(domNode.isElement())
        {
            QDomElement  domElement  = domNode.toElement();
            if(!domElement.isNull())
            {
                if(domElement.tagName()=="OP")
                {
                    //qDebug()<<  "Attr: "<<domElement.attribute("numЬer","");
                }
                else
                {
                    xml.insert(domElement.tagName(),domElement.text());//тут ошибка
                    qDebug()<<"TagName:"<<domElement.tagName()<<"\tText:"<< domElement.text();
                    //xml[domElement.tagName()] = domElement.text();
                    qDebug()<<"TagName:"<<domElement.tagName()<<"\tText:"<<xml[domElement.tagName()];
                }
            }
        }
        traverseNode(domNode);
        domNode = domNode.nextSibling();
    }
}
bool iXMLReader::Validate()
{
    return true;
}
//...
QDomDocument  domDoc;
    QFile  file ("1.xml") ;
    if(file.open(QIODevice::ReadOnly))  {
        if(domDoc.setContent(&file)){
            QDomElement domElement=domDoc.documentElement();
            i->traverseNode(domElement);
        }
        file.close();
    }

 , , ,

doomer
()

Ошибка qt с++

#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QXmlSchemaValidator>
#include <QXmlSchema>
#include <QFile>
#include <QtDebug>
#include <QAbstractMessageHandler>
class MessageHandler : public QAbstractMessageHandler {
public:
    MessageHandler() : QAbstractMessageHandler(nullptr) {}

    QString statusMessage() const { return m_description; }
    int line() const { return m_sourceLocation.line(); }
    int column() const { return m_sourceLocation.column(); }

protected:
    void handleMessage(QtMsgType type, const QString &description,
                       const QUrl &identifier, const QSourceLocation &sourceLocation) override {
        Q_UNUSED(type);
        Q_UNUSED(identifier);
        m_description = description;
        m_sourceLocation = sourceLocation;
    }

private:
    QString m_description;
    QSourceLocation m_sourceLocation;
};

void validateXML(const QString &schemaPath, const QString &xmlPath) {
    QFile xsdFile(schemaPath);
    if (!xsdFile.open(QIODevice::ReadOnly)) {
        qDebug() << "Failed to open schema file.";
        return;
    }

    MessageHandler messageHandler;
    QXmlSchema schema;
    schema.setMessageHandler(&messageHandler);

    if (!schema.load(&xsdFile, QUrl::fromLocalFile(xsdFile.fileName()))) {
        qDebug() << "Schema loading failed.";
        qDebug() << "Error:" << messageHandler.statusMessage();
        qDebug() << "Line:" << messageHandler.line();
        qDebug() << "Column:" << messageHandler.column();
        return;
    }

    QFile xmlFile(xmlPath);
    if (!xmlFile.open(QIODevice::ReadOnly)) {
        qDebug() << "Failed to open XML file.";
        return;
    }

    QXmlSchemaValidator validator(schema);
    if (!validator.validate(&xmlFile, QUrl::fromLocalFile(xmlFile.fileName()))) {
        qDebug() << "XML validation failed.";
        qDebug() << "Error:" << messageHandler.statusMessage();
        qDebug() << "Line:" << messageHandler.line();
        qDebug() << "Column:" << messageHandler.column();
    } else {
        qDebug() << "XML is valid.";
    }
}
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    validateXML("1.xsd","1.xml");
}

MainWindow::~MainWindow()
{
    delete ui;
}
ASSERT failure in virtual qulonglong QPatternist::Decimal::toUnsignedInteger() const: "It makes no sense to call this function, see Numeric::toUnsignedInteger().", file data\qdecimal.cpp, line 174

 , , ,

doomer
()

RSS подписка на новые темы