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. Crash when using QFile::copy
Forum Updated to NodeBB v4.3 + New Features

Crash when using QFile::copy

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.7k 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.
  • L Offline
    L Offline
    Leon
    wrote on last edited by
    #1

    Hello i am kinda in the same position as my friend.. This code:

    @
    if (!QDir(home_special).exists())
    {
    QDir dir;
    dir.mkpath(home_special);
    }
    else
    {

        QDir dir_get_all_pictures;
        dir_get_all_pictures.setPath(home_neobux);
        dir_get_all_pictures.setFilter(QDir::Files);
        QStringList filters;
        filters << "avatar*";
        QStringList all_files=dir_get_all_pictures.entryList(filters);
        int all_files_count = all_files.count();
        for (int i=0;all_files_count>i;i++)
            QFile&#40;home_special+all_files.at(i&#41;&#41;.remove(&#41;;
    }
    
    QFile::copy(path, home_special+"avatar"+fullname);
    ui->avatar_label->setPixmap(home_special+"avatar"+fullname);@
    

    What the code does is, if the directory doesn't exist create it and copy an image while renaming the image to avatar. If the folder exists delete everything that is on the folder and starts from avatar, then copy the image and rename it avatar. Well this code works perfectly in Ubuntu, i just tested it in Windows and i get:

    !http://i.imgur.com/jce49.png(1)!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      scroverty
      wrote on last edited by
      #2

      @Leon: I think "home_special+"avatar"+fullname" need some seperator, correct me if I'm wrong.

      Alvis Ar'Berkeley Andrew.
      Pleased to meet you!

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Leon
        wrote on last edited by
        #3

        [quote author="A.A.B.A" date="1348203790"]@Leon: I think "home_special+"avatar"+fullname" need some seperator, correct me if I'm wrong.[/quote]

        It wasn't the slashes problem.. the code i have posted here works perfectly, it was buggy in the part before this code :D..

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #4

          Leon: please don't hijack other threads with "similar" problems. I splitted your messages.

          Could you please add a [solved] in this thread's title and a description of the solution? Thanks.

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

          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