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. Questions in the path to files instead of Cyrillic.
QtWS25 Last Chance

Questions in the path to files instead of Cyrillic.

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 5 Posters 1.6k Views
  • 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.
  • H Offline
    H Offline
    haifisch
    wrote on last edited by haifisch
    #1

    Why did the questions appear in the path to file?

    "D:/My Programs/build-ObservationLog-Desktop_Qt_5_11_0_MSVC2017_64bit-Debug/Журнал_0_Пн_июн_25_2018/Видеокамера/00887.MTS"
    ShellExecute 'file:///D:/My Programs/build-ObservationLog-Desktop_Qt_5_11_0_MSVC2017_64bit-Debug/??????_0_??_???_25_2018/???????????/00887.MTS' failed (error 2).
    

    I changed the compiler from mingw to MSVC2017. After that there was a problem. But this is only an assumption. How to change the code so that links work?

    bool HrefDelegate::editorEvent(QEvent *event,
                                       QAbstractItemModel *model,
                                       const QStyleOptionViewItem &option,
                                       const QModelIndex &index) {
        if ((event->type() == QEvent::MouseButtonRelease) || (event->type() == QEvent::MouseButtonDblClick)) {
            if (index.row()!=0) {
                //QUrl url = index.model()->data(index, Qt::DisplayRole).toUrl();
                QDesktopServices::openUrl(QUrl::fromUserInput(index.model()->data(index, Qt::DisplayRole).toString()));
                return true;
            }
    
        }
        return false;
    }
    
    aha_1980A 1 Reply Last reply
    0
    • H haifisch

      Why did the questions appear in the path to file?

      "D:/My Programs/build-ObservationLog-Desktop_Qt_5_11_0_MSVC2017_64bit-Debug/Журнал_0_Пн_июн_25_2018/Видеокамера/00887.MTS"
      ShellExecute 'file:///D:/My Programs/build-ObservationLog-Desktop_Qt_5_11_0_MSVC2017_64bit-Debug/??????_0_??_???_25_2018/???????????/00887.MTS' failed (error 2).
      

      I changed the compiler from mingw to MSVC2017. After that there was a problem. But this is only an assumption. How to change the code so that links work?

      bool HrefDelegate::editorEvent(QEvent *event,
                                         QAbstractItemModel *model,
                                         const QStyleOptionViewItem &option,
                                         const QModelIndex &index) {
          if ((event->type() == QEvent::MouseButtonRelease) || (event->type() == QEvent::MouseButtonDblClick)) {
              if (index.row()!=0) {
                  //QUrl url = index.model()->data(index, Qt::DisplayRole).toUrl();
                  QDesktopServices::openUrl(QUrl::fromUserInput(index.model()->data(index, Qt::DisplayRole).toString()));
                  return true;
              }
      
          }
          return false;
      }
      
      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        What do you get if you use: index.model()->data(index, Qt::DisplayRole).toString().toUtf8() ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        H 2 Replies Last reply
        1
        • SGaistS SGaist

          Hi,

          What do you get if you use: index.model()->data(index, Qt::DisplayRole).toString().toUtf8() ?

          H Offline
          H Offline
          haifisch
          wrote on last edited by
          #4

          @SGaist If .toUtf8()

          qDebug()<<index.model()->data(index, Qt::DisplayRole).toString().toUtf8();
                     QDesktopServices::openUrl(QUrl::fromUserInput(index.model()->data(index, Qt::DisplayRole).toString().toUtf8()));
          
           console:     
          
          "D:/My Programs/build-ObservationLog-Desktop_Qt_5_11_0_MSVC2017_64bit-Debug/\xD0\x96\xD1\x83\xD1\x80\xD0\xBD\xD0\xB0\xD0\xBB_0_\xD0\x92\xD1\x82_\xD0\xB8\xD1\x8E\xD0\xBD_26_2018/\xD0\x92\xD0\xB8\xD0\xB4\xD0\xB5\xD0\xBE\xD0\xBA\xD0\xB0\xD0\xBC\xD0\xB5\xD1\x80\xD0\xB0/00891.MTS"
          ShellExecute 'file:///D:/My Programs/build-ObservationLog-Desktop_Qt_5_11_0_MSVC2017_64bit-Debug/??????_0_??_???_26_2018/???????????/00891.MTS' failed (error 2).
          
          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            What do you get if you use: index.model()->data(index, Qt::DisplayRole).toString().toUtf8() ?

            H Offline
            H Offline
            haifisch
            wrote on last edited by
            #5

            @SGaist

                    ```
            

            QTextCodec *codec_1251 = QTextCodec::codecForName("Windows-1251");
            QString string = codec_1251->toUnicode(index.model()->data(index, Qt::DisplayRole).toByteArray());
            QDesktopServices::openUrl(QUrl::fromUserInput(string));

            Now there are no questions in the path to the file. 
            But :
            

            ShellExecute 'file:///D:/My Programs/build-ObservationLog-Desktop_Qt_5_11_0_MSVC2017_64bit-Debug/Журнал_0_Вт_июн_26_2018/Видеокамера/00884.MTS' failed (error 2).

            ShellExecute  failed (error 2)
            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @haifisch said in Questions in the path to files instead of Cyrillic.:

              ShellExecute

              As far as i know it dont like unicode letters. ( its ansi)
              Only ShellExecuteW understands them.

              H 1 Reply Last reply
              1
              • mrjjM mrjj

                @haifisch said in Questions in the path to files instead of Cyrillic.:

                ShellExecute

                As far as i know it dont like unicode letters. ( its ansi)
                Only ShellExecuteW understands them.

                H Offline
                H Offline
                haifisch
                wrote on last edited by
                #7

                @mrjj What do you suggest changing in the code?

                mrjjM 1 Reply Last reply
                0
                • H haifisch

                  @mrjj What do you suggest changing in the code?

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @haifisch
                  Hi
                  Since you seem to call
                  QDesktopServices::openUrl and im not sure we can make it call the W version
                  i was wondering if the u thing can fix it.
                  https://github.com/inasafe/inasafe/issues/1879
                  or if it simply wants
                  QDesktopServices::openUrl(QUrl::fromLocalFile(file));

                  H 1 Reply Last reply
                  1
                  • mrjjM mrjj

                    @haifisch
                    Hi
                    Since you seem to call
                    QDesktopServices::openUrl and im not sure we can make it call the W version
                    i was wondering if the u thing can fix it.
                    https://github.com/inasafe/inasafe/issues/1879
                    or if it simply wants
                    QDesktopServices::openUrl(QUrl::fromLocalFile(file));

                    H Offline
                    H Offline
                    haifisch
                    wrote on last edited by
                    #9

                    @mrjj QDesktopServices::openUrl(QUrl(u"file:///"+index.model()->data(index, Qt::DisplayRole).toString())); Errors, I do not understand how wrapping the url u ''

                    kshegunovK 1 Reply Last reply
                    0
                    • H haifisch

                      @mrjj QDesktopServices::openUrl(QUrl(u"file:///"+index.model()->data(index, Qt::DisplayRole).toString())); Errors, I do not understand how wrapping the url u ''

                      kshegunovK Offline
                      kshegunovK Offline
                      kshegunov
                      Moderators
                      wrote on last edited by
                      #10

                      Have you tried using your local 8bit encoding, instead of converting it to a unicode?

                      Read and abide by the Qt Code of Conduct

                      H 1 Reply Last reply
                      0
                      • kshegunovK kshegunov

                        Have you tried using your local 8bit encoding, instead of converting it to a unicode?

                        H Offline
                        H Offline
                        haifisch
                        wrote on last edited by
                        #11

                        @kshegunov How to convert it to unicode?

                        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