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. QString and BSTR
Forum Updated to NodeBB v4.3 + New Features

QString and BSTR

Scheduled Pinned Locked Moved General and Desktop
26 Posts 3 Posters 19.3k 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.
  • G Offline
    G Offline
    giesbert
    wrote on last edited by
    #6

    Hi kitten,

    where do you get which error?
    Did you try to debug it?

    The conversion from QString to BSTR looks generally correct.

    Nokia Certified Qt Specialist.
    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #7

      By the way, do you need a BSTR*?
      in the parameters, you write:

      @
      (void*)&test...
      @

      a BSTR is already a pointer....

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kitten
        wrote on last edited by
        #8

        i use this but it get me error again
        @void _a[] = {(void)&qax_result, (void*)&Row, (void*)&Col, (void*)test};@
        it get me error on this file
        qatomic_windows.h
        on function
        @inline bool QBasicAtomicInt::ref()@

        www.kitten.mihanblog.com

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cincirin
          wrote on last edited by
          #9

          I did a little test, and it works perfectly:
          @
          QString string("test");
          BSTR bstr = SysAllocString(reinterpret_cast<const OLECHAR*>(string.utf16()));
          char testing[] = {bstr[0], bstr[1], bstr[2], bstr[3], '\0'};
          qDebug(testing);
          SysFreeString(bstr);
          @

          debug window show "test"

          1 Reply Last reply
          0
          • C Offline
            C Offline
            cincirin
            wrote on last edited by
            #10

            Just out of curiosity, if you delete last parameter(test) from _a array, the problem still exists ?

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #11

              [quote author="kitten" date="1316007780"]i use this but it get me error again
              @void _a[] = {(void)&qax_result, (void*)&Row, (void*)&Col, (void*)test};@
              it get me error on this file
              qatomic_windows.h
              on function

              @
              inline bool QBasicAtomicInt::ref()
              @
              [/quote]

              Which error message do you get???

              this is just a parameter assignement, nothing else

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kitten
                wrote on last edited by
                #12

                it work correctly
                do you what i want to do?
                i have a .net dll now i want to write a program for it
                i use dumpcpp to use it , it works correctly and this functions work correctly too
                but when i send a text of other languages like persian to this dll it show me ???? in replace of my text

                www.kitten.mihanblog.com

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  kitten
                  wrote on last edited by
                  #13

                  !http://www.pic.iran-forum.ir/images/81rzhse7v2t3wujmtb1.jpg(error)!
                  [quote author="Gerolf" date="1316008510"][quote author="kitten" date="1316007780"]i use this but it get me error again
                  @void _a[] = {(void)&qax_result, (void*)&Row, (void*)&Col, (void*)test};@
                  it get me error on this file
                  qatomic_windows.h
                  on function
                  @inline bool QBasicAtomicInt::ref()@[/quote]

                  Which error message do you get???

                  this is just a parameter assignement, nothing else[/quote]

                  www.kitten.mihanblog.com

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    giesbert
                    wrote on last edited by
                    #14

                    which is the call stack?

                    Nokia Certified Qt Specialist.
                    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      kitten
                      wrote on last edited by
                      #15

                      what do you mean by call stack?

                      www.kitten.mihanblog.com

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        cincirin
                        wrote on last edited by
                        #16

                        In Visual Studio is: Debug -> Windows -> Call Stack

                        1 Reply Last reply
                        0
                        • K Offline
                          K Offline
                          kitten
                          wrote on last edited by
                          #17

                          this is my call stack when i got error
                          !http://www.pic.iran-forum.ir/images/vpo7zgu8y0gdpbw6id4l.jpg(call stack)!

                          www.kitten.mihanblog.com

                          1 Reply Last reply
                          0
                          • C Offline
                            C Offline
                            cincirin
                            wrote on last edited by
                            #18

                            [quote author="kitten" date="1316008652"]it work correctly
                            i use dumpcpp to use it , it works correctly and this functions work correctly too
                            but when i send a text of other languages like persian to this dll it show me ???? in replace of my text
                            [/quote]

                            What work correctly ? When your program crashes ?
                            Also for persian and arabic conversion, maybe "PAText wiki":http://developer.qt.nokia.com/wiki/QPlugs_PAText_Add_Persian_and_Arabic_support_to_WindowsCE_Mobile_applications will help you

                            1 Reply Last reply
                            0
                            • K Offline
                              K Offline
                              kitten
                              wrote on last edited by
                              #19

                              it is generated with dumpcpp
                              if i use the default it work corrctly on english language
                              but in persian language it doesn't work correctly

                              www.kitten.mihanblog.com

                              1 Reply Last reply
                              0
                              • G Offline
                                G Offline
                                giesbert
                                wrote on last edited by
                                #20

                                How do you enter persian text?
                                The shown call stack is too short, please copy it out of the call stack window and post it as text.

                                Nokia Certified Qt Specialist.
                                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                                1 Reply Last reply
                                0
                                • K Offline
                                  K Offline
                                  kitten
                                  wrote on last edited by
                                  #21

                                  @> QtCored4.dll!QBasicAtomicInt::ref() Line 319 + 0x8 bytes C++
                                  QtCored4.dll!QString::QString(const QString & other={...}) Line 729 + 0x51 bytes C++
                                  QtCored4.dll!v_construct<QString>(QVariant::Private * x=0x0030f4b0, const void * copy=0x0070c05c, QString * formal=0x00000000) Line 117 + 0x2a bytes C++
                                  QtCored4.dll!construct(QVariant::Private * x=0x0030f4b0, const void * copy=0x0070c05c) Line 81 + 0xf bytes C++
                                  QtGuid4.dll!construct(QVariant::Private * x=0x0030f4b0, const void * copy=0x0070c05c) Line 182 + 0x12 bytes C++
                                  QtCored4.dll!QVariant::create(int type=10, const void * copy=0x0070c05c) Line 1391 + 0x11 bytes C++
                                  QtCored4.dll!QVariant::QVariant(int typeOrUserType=10, const void * copy=0x0070c05c) Line 1670 + 0x1f bytes C++
                                  new qt finger.exe!QAxBase::internalInvoke() + 0x43c bytes
                                  new qt finger.exe!QAxBase::qt_metacall() + 0x19f bytes
                                  new qt finger.exe!QAxWidget::qt_metacall() + 0x41 bytes
                                  new qt finger.exe!zkemkeeper::CZKEM::WriteLCD(int Row=5, int Col=5, const QString & Text={...}) Line 4828 C++
                                  new qt finger.exe!newqtfinger::newqtfinger(QWidget * parent=0x00000000, QFlags<enum Qt::WindowType> flags={...}) Line 13 + 0x31 bytes C++
                                  new qt finger.exe!main(int argc=1, char * * argv=0x022164a8) Line 6 + 0x17 bytes C++
                                  new qt finger.exe!WinMain(HINSTANCE
                                  * instance=0x00890000, HINSTANCE__ * prevInstance=0x00000000, char * __formal=0x006f5eae, int cmdShow=1) Line 131 + 0x12 bytes C++
                                  new qt finger.exe!__tmainCRTStartup() Line 574 + 0x35 bytes C
                                  new qt finger.exe!WinMainCRTStartup() Line 399 C
                                  kernel32.dll!76e733ca()
                                  [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
                                  ntdll.dll!778f9ed2()
                                  ntdll.dll!778f9ea5()
                                  @

                                  www.kitten.mihanblog.com

                                  1 Reply Last reply
                                  0
                                  • K Offline
                                    K Offline
                                    kitten
                                    wrote on last edited by
                                    #22

                                    i think it isn't about persian
                                    because when i use this conversion english does'nt work too

                                    www.kitten.mihanblog.com

                                    1 Reply Last reply
                                    0
                                    • G Offline
                                      G Offline
                                      giesbert
                                      wrote on last edited by
                                      #23

                                      How is the persian text entered?
                                      how does zkemkeeper::CZKEM::WriteLCD(...) look like?

                                      Nokia Certified Qt Specialist.
                                      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                                      1 Reply Last reply
                                      0
                                      • K Offline
                                        K Offline
                                        kitten
                                        wrote on last edited by
                                        #24

                                        this is my function i want to use it
                                        @
                                        inline bool CZKEM::WriteLCD(int Row, int Col, const QString& Text){
                                        bool qax_result;
                                        QString st("mil");
                                        BSTR test = SysAllocString(st.utf16());
                                        _bstr_t te(test);
                                        void _a[] = {(void)&qax_result, (void*)&Row, (void*)&Col, (void*)test};
                                        qt_metacall(QMetaObject::InvokeMetaMethod, 244, _a);
                                        SysFreeString(test);
                                        return qax_result;
                                        }
                                        @

                                        and this is a function generated with dumpcpp
                                        @inline bool CZKEM::WriteLCD(int Row, int Col, const QString& Text)
                                        {
                                        bool qax_result;
                                        void _a[] = {(void)&qax_result, (void*)&Row, (void*)&Col, (void*)&Text};
                                        qt_metacall(QMetaObject::InvokeMetaMethod, 244, _a);
                                        return qax_result;
                                        }@

                                        i am changing the function

                                        www.kitten.mihanblog.com

                                        1 Reply Last reply
                                        0
                                        • G Offline
                                          G Offline
                                          giesbert
                                          wrote on last edited by
                                          #25

                                          Looks like the function needs a QString, why do you manually change the QString to BSTR? QAxXXX uses Qt datatypes.

                                          Nokia Certified Qt Specialist.
                                          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                                          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