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. directoryOf function QT4 -> QT5
Forum Updated to NodeBB v4.3 + New Features

directoryOf function QT4 -> QT5

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 5 Posters 580 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.
  • S Offline
    S Offline
    sandro4912
    wrote on last edited by
    #1

    I came across the following code snippet written with QT4:

    void HelpBrowser::showPage(const QString &page)
    {
        
        auto path = directoryOf("doc").absolutePath();
        auto browser = new HelpBrowser(path, page);
        browser->resize(500, 400);
        browser->show();
    }
    

    However in Qt5 i cant find the function directoryOf(). Does it still exist?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @sandro4912 said in directoryOf function QT4 -> QT5:

      directoryOf

      In which class was it in Qt4? I'm not aware that such a function exists in Qt4 at all.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by SGaist
        #3

        Hi,

        What is HelpBrowser ?

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

        1 Reply Last reply
        2
        • JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @sandro4912 said in directoryOf function QT4 -> QT5:

          HelpBrowser
          directoryOf

          It's from here http://www.informit.com/articles/article.aspx?p=1405554&seqNum=4
          C++ GUI Programming with Qt4: Providing Online Help

          :)

          And to the OP: all the code is written by the author in the book, it doesn't come with Qt.

          1 Reply Last reply
          3
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            HelpBrowser::directoryOf() is a custom function written by someone but not Qt. So you will likely not find it in any Qt class but in the HelpBrowser implementation which you will find in the book I guess.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            3
            • S Offline
              S Offline
              sandro4912
              wrote on last edited by
              #6

              Yeah i got it now. I overread it in the mentioned book. If youre currious. The function does this:

              QDir MainWindow::directoryOf(const QString &subdir)
              {
                  QDir dir(QApplication::applicationDirPath());
              
              #if defined(Q_OS_WIN)
                  if (dir.dirName().toLower() == "debug"
                          || dir.dirName().toLower == "release")
                      dir.cdUp();
              #elif defined(Q_OS_MAC)
                  if (dir.dirName() == "MacOS") {
                      dir.cdUp();
                      dir.cdUp();
                      dir.cdUp();
                  }
              #endif
                  dir.cd(subdir);
                  return dir;
              }
              
              aha_1980A 1 Reply Last reply
              1
              • S sandro4912

                Yeah i got it now. I overread it in the mentioned book. If youre currious. The function does this:

                QDir MainWindow::directoryOf(const QString &subdir)
                {
                    QDir dir(QApplication::applicationDirPath());
                
                #if defined(Q_OS_WIN)
                    if (dir.dirName().toLower() == "debug"
                            || dir.dirName().toLower == "release")
                        dir.cdUp();
                #elif defined(Q_OS_MAC)
                    if (dir.dirName() == "MacOS") {
                        dir.cdUp();
                        dir.cdUp();
                        dir.cdUp();
                    }
                #endif
                    dir.cd(subdir);
                    return dir;
                }
                
                aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi @sandro4912,

                so you can mark this topic as SOLVED now. Thanks!

                Qt has to stay free or it will die.

                1 Reply Last reply
                1
                • S Offline
                  S Offline
                  sandro4912
                  wrote on last edited by
                  #8

                  Yeah i already marked it. I Gues ś questions like this happen after coding to many hours...

                  1 Reply Last reply
                  1

                  • Login

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