Results 1 to 3 of 3

Thread: QString::fromStdWString() doesn't work ...

  1. #1
    Join Date
    Mar 2006
    Location
    Moldova
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy QString::fromStdWString() doesn't work ...

    Hi guys, i have this peace of code:

    //-------------------------------------------------------------------------------//
    #include <QtGui>
    #include <windows.h>
    #include <lm.h>
    .................................................. ...................
    PSHARE_INFO_502 BufPtr,p;
    NET_API_STATUS res;
    DWORD er=0,tr=0,resume=0, i;
    QString *str = new QString;
    QTreeWidgetItem *rootItem = new QTreeWidgetItem(SharesTree);
    rootItem->setText(0,"My Shares");
    QTreeWidgetItem *item;

    do
    {
    res = NetShareEnum (NULL, 502, (LPBYTE *) &BufPtr, -1, &er, &tr, &resume);
    if(res == ERROR_SUCCESS || res == ERROR_MORE_DATA)
    {
    p=BufPtr;
    for(i=1;i<=er;i++)
    {
    item = new QTreeWidgetItem(rootItem);
    str->fromStdWString(p->shi502_netname);
    item->setText(0,str);
    p++;
    }
    NetApiBufferFree(BufPtr);
    }
    }
    while (res==ERROR_MORE_DATA);

    SharesTree->expandItem(rootItem);
    .................................................. ............................
    //----------------------------------------------------------------------------------------//

    I'm using Qt4.1.1_opensource_mingw on Windows. It was configured like this:
    configure -stl
    and then
    make

    The program is building with success, but the fromStdWString function doesn't work ... What's wrong ??

    Thanks a lot ...
    Last edited by jsmax; 15th March 2006 at 16:57. Reason: better explanation :)
    All Rights Reserved ...

  2. #2
    Join Date
    Mar 2006
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QString::fromStdWString() doesn't work ...

    fromStdWString doesn't modify the string passed in, it returns a modified copy. Try assigning the return value to a temporary QString and passing that to setText().

  3. #3
    Join Date
    Mar 2006
    Location
    Moldova
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QString::fromStdWString() doesn't work ...

    Thanks a lot ! It works ! I did it like that:

    QString str;

    item = new QTreeWidgetItem(rootItem);
    str = QString::fromStdWString(p->shi502_netname);
    item->setText(0,str);
    All Rights Reserved ...

Similar Threads

  1. signal of QListWidget doesn't work
    By vito49 in forum Qt Programming
    Replies: 10
    Last Post: 1st October 2008, 05:07
  2. Qt4 : QPainter::setRedirected doesn't work
    By Ankitha Varsha in forum Qt Programming
    Replies: 2
    Last Post: 20th June 2008, 17:52
  3. QActions don't work with menubar hidden
    By Pepe in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2007, 01:04
  4. Change work area OS
    By pakulo in forum Qt Programming
    Replies: 15
    Last Post: 15th May 2007, 07:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.