Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. ActiveQT problem with the transfer Russian characters!!!
Forum Updated to NodeBB v4.3 + New Features

ActiveQT problem with the transfer Russian characters!!!

Scheduled Pinned Locked Moved General and Desktop
17 Posts 4 Posters 9.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _KUL
    wrote on last edited by
    #1

    Hello!
    There is a need to connect to the server through 1C "Your text to link here...":http://1c.ru/ atstiveks COM.
    When using English-language queries, there is no problem, but if you use the Russian names of the parameters (1C is a Russian system for financial accounting), an error occurs when calling methods:
    QAxObject :: querySubObject
    QAxBase :: dynamicCallHelper
    Solving this problem using Qt 4.8 (because it has the support of the functions)

    main.cpp UTF-8
    @
    #include <QApplication>
    #include <oleauto.h>
    #include <ActiveQt/QAxObject>
    #include <QAxBase>
    #include <QDebug>
    #include <QTextCodec>
    #include <QString>
    #include <QByteArray>

    int main(int argc, char *argv[])
    {

    QCoreApplication a(argc, argv);
    ::OleInitialize(0);
    
    setlocale(LC_ALL, "Russian");
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    
    qDebug() << "текст2";
    QAxObject * ax = new QAxObject("V82.COMConnector");
    QAxObject * ac = ax->querySubObject("Connect(\"Srvr=\"172.0.0.100\";Ref=\"base1\";Usr=\"1C-Bot\";Pwd=\"56q\";\")");
    
    QAxObject * ab = ac->querySubObject("ПользователиИнформационнойБазы");
    
    delete ax;
    
    qDebug() << "end";
    return a.exec&#40;&#41;;
    

    }
    @

    Result
    @
    QAxBase::dynamicCallHelper: ПользователиИнформационнойБазы: No such property in
    [unknown]
    Candidates are:
    end
    @

    I read on the forum that the COM server 1C takes CP1251 encoding and returns the result UTF-8.

    main.cpp UTF-8
    @
    #include <QApplication>
    #include <oleauto.h>
    #include <ActiveQt/QAxObject>
    #include <QAxBase>
    #include <QDebug>
    #include <QTextCodec>
    #include <QString>
    #include <QByteArray>

    int main(int argc, char *argv[])
    {

    QCoreApplication a(argc, argv);
    ::OleInitialize(0);
    
    setlocale(LC_ALL, "Russian");
    [B]QTextCodec::setCodecForTr(QTextCodec::codecForName("Windows-1251"));[/B]
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    
    qDebug() << "текст2";
    QAxObject * ax = new QAxObject("V82.COMConnector");
    QAxObject * ac = ax->querySubObject("Connect(\"Srvr=\"172.0.0.100\";Ref=\"base1\";Usr=\"1C-Bot\";Pwd=\"56q\";\")");
    
    [B]QAxObject * ab = ac->querySubObject(QAxObject::tr("ПользователиИнформационнойБазы").toAscii());[/B]
    
    delete ax;
    
    qDebug() << "end";
    return a.exec&#40;&#41;;
    

    }@

    Result
    @QAxBase::dynamicCallHelper: Р?Р?Р>С?Р·Р?Р?Р°С'РчР>РёР?Р?С"Р?С?Р?Р°С┼РёР?Р?Р?Р?Р№
    Р'азС<: No such property in [unknown]
    Candidates are:
    end@

    Why is this happening?

    If you use Visual Basic 2010
    @Module Module1

    Sub Main(&#41;
        Dim cntr As Object
        Dim trade As Object
        Dim allusers As Object
        Dim users As Object
    
        Dim line As String
    
        cntr = CreateObject("V82.COMConnector")
        trade = cntr.Connect("Srvr=""172.0.0.100"";Ref=""base1"";Usr=""1C-Bot"";Pwd=""56q"";")
        allusers = trade.ПользователиИнформационнойБазы
        users = allusers.НайтиПоИмени("admin")
        Console.WriteLine(users.Имя)
        Console.WriteLine(users.АутентификацияОС)
    
        Console.WriteLine("end")
    
        line = Console.ReadLine()
    
    End Sub
    

    End Module@
    Then everything is working properly! ;(

    1 Reply Last reply
    0
    • _ Offline
      _ Offline
      _KUL
      wrote on last edited by
      #2

      is uppps ...

      1 Reply Last reply
      0
      • _ Offline
        _ Offline
        _KUL
        wrote on last edited by
        #3

        is up

        1 Reply Last reply
        0
        • T Offline
          T Offline
          terenty
          wrote on last edited by
          #4

          Hi,
          Clearly It has something to do with encoding...
          try this:

          @QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Windows-1251"));

          querySubObject(QString("ПользователиИнформационнойБазы").toAscii());@

          1 Reply Last reply
          0
          • _ Offline
            _ Offline
            _KUL
            wrote on last edited by
            #5

            main.cpp UTF-8

            @#include <QCoreApplication>
            #include <oleauto.h>
            #include <ActiveQt/QAxObject>
            #include <QAxBase>
            #include <QDebug>
            #include <QTextCodec>
            #include <QString>
            #include <QByteArray>
            #include <iostream>

            int main(int argc, char *argv[])
            {
            ::OleInitialize(0);
            QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Windows-1251"));

            QAxObject * ax = new QAxObject("V82.COMConnector");
            QAxObject * ac = ax->querySubObject("Connect(\"Srvr=\"172.0.0.100\";Ref=\"base1\";Usr=\"1C-Bot\";Pwd=\"56q\";\")");
            
            QAxObject * ab = ac->querySubObject(QString("ПользователиИнформационнойБазы").toAscii());
            
            delete ax;
            
            qDebug() << "end";
            //return a.exec&#40;&#41;;
            

            }@

            Result

            @QAxBase::dynamicCallHelper: ¦юы№чютрЄхыш??эЇюЁьрЎшюээющ+рчv: No such property in
            [unknown]
            Candidates are:
            end@

            main.cpp Windows-1251

            Result

            @QAxBase::dynamicCallHelper: ??????????????????????????????: No such property in
            [unknown]
            Candidates are:
            end@

            If you use the English names (NOTE: always use English names will not work, because there are methods and objects in Russian)

            main.cpp Windows-1251
            @
            QAxObject * ab = ac->querySubObject(QString("InfoBaseUsers").toAscii());@

            Result
            @end@

            1 Reply Last reply
            0
            • T Offline
              T Offline
              terenty
              wrote on last edited by
              #6

              Try this:

              @QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Windows-1251"));

              querySubObject(QString::fromWCharArray(L"ПользователиИнформационнойБазы").toUtf8());@

              on my system this prints the correct symbols to qDebug() :

              @QAxBase::dynamicCallHelper: ПользователиИнформационнойБазы: No such property in {419FEC50-AB6C-49EB-A315-F49E5F804E8D} [unknown]
              Candidates are:@

              but in case this won't work you can also try this:
              @QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Windows-1251"));

              querySubObject(QString::fromWCharArray(L"ПользователиИнформационнойБазы").toAscii());@

              EDIT1:
              By the way, assuming that you work in MSVC2010, if you get some LINK error complaining about QString::fromWCharArray go to your Project properties > C/C++ > Language > Treat wchar_t as Built-in Type set to false

              1 Reply Last reply
              0
              • _ Offline
                _ Offline
                _KUL
                wrote on last edited by
                #7

                @
                #include <QCoreApplication>
                #include <oleauto.h>
                #include <ActiveQt/QAxObject>
                #include <QAxBase>
                #include <QDebug>
                #include <QTextCodec>
                #include <QString>
                #include <QByteArray>
                #include <iostream>

                int main(int argc, char *argv[])
                {
                ::OleInitialize(0);
                setlocale(LC_ALL, "Russian");

                QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Windows-1251"));
                qDebug() << QString::fromWCharArray(L"ПользователиИнформационнойБазы").toAscii();

                QAxObject * ax = new QAxObject("V82.COMConnector");
                QAxObject * ac = ax->querySubObject("Connect(\"Srvr=\"172.0.0.100\";Ref=\"base1\";Usr=\"1C-Bot\";Pwd=\"56q\";\")");
                
                QAxObject * ab = ac->querySubObject(QString::fromWCharArray(L"ПользователиИнформационнойБазы").toAscii());
                
                delete ax;
                
                qDebug() << "end";
                

                }
                @

                Result
                @"ПользователиИнформационнойБазы"
                QAxBase::dynamicCallHelper: ??????????????????????????????: No such property in
                [unknown]
                Candidates are:
                end@

                1 Reply Last reply
                0
                • _ Offline
                  _ Offline
                  _KUL
                  wrote on last edited by
                  #8

                  Using pure Qt 4.8.5
                  Well you guessed thought about MS VS2010. I will think how to tie the Qt libraries to VS2010.

                  Не знаю на сколько правильно мысль перевел translate.google.ru, на всякий случай по русски напишу :)
                  Использую чистый Qt 4.8.5
                  Хорошу вы мысль предположили насчёт MS VS2010. Буду думать, как библиотеки Qt прикрутить к VS2010.

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    terenty
                    wrote on last edited by
                    #9

                    --

                    --

                    Did this one:
                    @QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Windows-1251"));

                    querySubObject(QString::fromWCharArray(L"ПользователиИнформационнойБазы").toUtf8());@

                    also not work?

                    Тоесть я так понимаю ты сейчас в QtCreator'е сидишь? Думаю большой разницы не будет если в MSVC2010 переешь. Просто удобней если ты к студии привык.
                    Попробуй как я выше написал, если еще не пробовал, может прокатит наконецтаки )

                    Только тут как-бы по русски нельзя - начнут замечания делать :)

                    1 Reply Last reply
                    0
                    • _ Offline
                      _ Offline
                      _KUL
                      wrote on last edited by
                      #10

                      Ок, будем по инглишу через гугл транслейтер ...

                      tried and toUtf8 () and toAscii () does not work ...
                      I think that the problem is not in the coding and in the transformation, and in QAxBase class. For example, if the above view, it is displayed as correct as qDebug, and the interface itself is not true querySubObject takes. I tried to adjust the encoding to std::cout correctly deduced, and then tried to give ActiveX, did not work ... It's a shame that with all the fine words in English and Russian with error ... :(
                      As a fan of free software just sit under the Qt :)

                      1 Reply Last reply
                      0
                      • _ Offline
                        _ Offline
                        _KUL
                        wrote on last edited by
                        #11

                        I want to help :( ...

                        1 Reply Last reply
                        0
                        • B Offline
                          B Offline
                          b-s-a
                          wrote on last edited by
                          #12

                          Russian discussion is here:
                          http://forum.vingrad.ru/index.php?show_type=forum&showtopic=370551&kw=кодировка-ошибка

                          1 Reply Last reply
                          0
                          • _ Offline
                            _ Offline
                            _KUL
                            wrote on last edited by
                            #13

                            I created the theme. There are solutions to this problem is not found, so I created a thread in the forum Qt.

                            1 Reply Last reply
                            0
                            • _ Offline
                              _ Offline
                              _KUL
                              wrote on last edited by
                              #14

                              up top my question

                              1 Reply Last reply
                              0
                              • _ Offline
                                _ Offline
                                _KUL
                                wrote on last edited by
                                #15

                                is up up

                                1 Reply Last reply
                                0
                                • _ Offline
                                  _ Offline
                                  _KUL
                                  wrote on last edited by
                                  #16

                                  anybody here?

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    snasoft
                                    wrote on last edited by
                                    #17

                                    [quote author="_KUL" date="1383200349"]anybody here?[/quote]

                                    Возможно ответ будет уже не актуален, но все же.

                                    QString::toLocal8Bit() пробовали?

                                    Еще (как вариант) можно перебрать различные кодировки (которые потенциально могут использоваться). Некий брутфорс. Я бы сделал это так: создал текстовый файл в одну строку ("ПользователиИнформационнойБазы"), потом считывал бы содержимое в QByteArray и передавал в querySubObject. Изменение кодировки выполняется например с помощью Notepad++.

                                    1 Reply Last reply
                                    0

                                    • Login

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • Users
                                    • Groups
                                    • Search
                                    • Get Qt Extensions
                                    • Unsolved