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. Newbie Help with Code
QtWS25 Last Chance

Newbie Help with Code

Scheduled Pinned Locked Moved Unsolved General and Desktop
layoutsource codemobile
11 Posts 3 Posters 1.8k 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.
  • N Offline
    N Offline
    Nuakount
    wrote on 13 May 2022, 13:31 last edited by
    #1

    Hi.

    I am new to QT, (and actually not much of a dev at all - I've mostly tinkered in Android code, and a little qml in SailfishOS over the years), and came here hoping for some help with adapting code in an app that I built from source, which runs fine, but is a bit buggy, since I built it and am running it on SailfishOS, (mobile), but it was made for desktop Linux.

    Let me know if a thread like this here is appropriate, or if there's a better place/approach, and I can get into the specifics...

    Thanks

    J 1 Reply Last reply 13 May 2022, 13:50
    0
    • N Nuakount
      13 May 2022, 13:31

      Hi.

      I am new to QT, (and actually not much of a dev at all - I've mostly tinkered in Android code, and a little qml in SailfishOS over the years), and came here hoping for some help with adapting code in an app that I built from source, which runs fine, but is a bit buggy, since I built it and am running it on SailfishOS, (mobile), but it was made for desktop Linux.

      Let me know if a thread like this here is appropriate, or if there's a better place/approach, and I can get into the specifics...

      Thanks

      J Offline
      J Offline
      JonB
      wrote on 13 May 2022, 13:50 last edited by
      #2

      @Nuakount
      This thread is fine, but now you need to ask some specific questions! :) Preferably related to Qt ;-) We cannot look at the whole of an app's code, what do you want to ask about it?

      N 1 Reply Last reply 13 May 2022, 14:27
      0
      • J JonB
        13 May 2022, 13:50

        @Nuakount
        This thread is fine, but now you need to ask some specific questions! :) Preferably related to Qt ;-) We cannot look at the whole of an app's code, what do you want to ask about it?

        N Offline
        N Offline
        Nuakount
        wrote on 13 May 2022, 14:27 last edited by Nuakount
        #3

        @JonB
        The app is Cantata - https://github.com/CDrummond/cantata. I built v2.4, because newer releases require qt>5.11, but I have 5.6, (and even v2.4 has some code that qt5.6 doesn't recognize, and that being the case, I also had to change a few things in the code, like changing all of the "horizontalAdvance"s to "width", [which I think could have something to do with one of my issues]).
        So to start with, I typically will launch it with QT_SCALE_FACTOR=3, since the default view is zoomed way out. This actually works very well, and everything is clear and present and nicely laid out. But, when I open Preferences dialog, the content goes off the screen. ..
        preferences:
        Screenshot_20220513_005.png
        main:
        Screenshot_20220513_004.png

        I have been able to workaround by adding rightMargin value to the .ui files associated with the particular preference options, (e.g. interfacesettings.ui), and I'm able to set preferences that way, (or by scaling way out and squinting...), but I wondered:

        • why does preferences dialog not fit it's content to the screen like the main window does, (or how to make it do it)
        • maybe forcing preferences dialog into 'portrait' mode would work
        • maybe possible to enable touch-scroll? As-is, touching acts basically like a mouse-hover, but won't grab anything

        We'll start with that... Any help?
        Thanks

        J 1 Reply Last reply 13 May 2022, 14:43
        0
        • N Nuakount
          13 May 2022, 14:27

          @JonB
          The app is Cantata - https://github.com/CDrummond/cantata. I built v2.4, because newer releases require qt>5.11, but I have 5.6, (and even v2.4 has some code that qt5.6 doesn't recognize, and that being the case, I also had to change a few things in the code, like changing all of the "horizontalAdvance"s to "width", [which I think could have something to do with one of my issues]).
          So to start with, I typically will launch it with QT_SCALE_FACTOR=3, since the default view is zoomed way out. This actually works very well, and everything is clear and present and nicely laid out. But, when I open Preferences dialog, the content goes off the screen. ..
          preferences:
          Screenshot_20220513_005.png
          main:
          Screenshot_20220513_004.png

          I have been able to workaround by adding rightMargin value to the .ui files associated with the particular preference options, (e.g. interfacesettings.ui), and I'm able to set preferences that way, (or by scaling way out and squinting...), but I wondered:

          • why does preferences dialog not fit it's content to the screen like the main window does, (or how to make it do it)
          • maybe forcing preferences dialog into 'portrait' mode would work
          • maybe possible to enable touch-scroll? As-is, touching acts basically like a mouse-hover, but won't grab anything

          We'll start with that... Any help?
          Thanks

          J Offline
          J Offline
          JonB
          wrote on 13 May 2022, 14:43 last edited by
          #4

          @Nuakount
          These are reasonable, specific questions --- good! :)

          I'm afraid I am not the person to answer these, but hopefully someone else will soon/in due course.

          was hoping to add some screenshots, but don't see option to attach local files. I can upload and link if you want

          You should be able to. On the "toolbar" above where you type in there should be a Picture button and an Upload Image button. The former is for a link to an external URL if you have it somewhere externally, the latter should prompt you to upload a local image file. Unless these are denied to newcomers, but I don't think so.

          N 1 Reply Last reply 15 May 2022, 02:45
          2
          • N Offline
            N Offline
            Nuakount
            wrote on 13 May 2022, 15:43 last edited by
            #5

            I "don't have enough priveleges" to attach files, but can paste code here if helpful....

            1 Reply Last reply
            0
            • N Offline
              N Offline
              Nuakount
              wrote on 13 May 2022, 16:33 last edited by Nuakount
              #6

              preferencesdialog.cpp:

              
               * Cantata
               *
               * Copyright (c) 2011-2020 Craig Drummond <craig.p.drummond@gmail.com>
               *
               * ----
               *
               * This program is free software; you can redistribute it and/or modify
               * it under the terms of the GNU General Public License as published by
               * the Free Software Foundation; either version 2 of the License, or
               * (at your option) any later version.
               *
               * This program is distributed in the hope that it will be useful,
               * but WITHOUT ANY WARRANTY; without even the implied warranty of
               * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
               * General Public License for more details.
               *
               * You should have received a copy of the GNU General Public License
               * along with this program; see the file COPYING.  If not, write to
               * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
               * Boston, MA 02110-1301, USA.
               */
              
              #include "preferencesdialog.h"
              #include "settings.h"
              #include "widgets/icons.h"
              #include "interfacesettings.h"
              #include "serversettings.h"
              #include "playbacksettings.h"
              #include "context/contextsettings.h"
              #include "cachesettings.h"
              #include "customactionssettings.h"
              #include "mpd-interface/mpdconnection.h"
              #ifdef ENABLE_PROXY_CONFIG
              #include "network/proxysettings.h"
              #endif
              #include "shortcutssettingspage.h"
              #if defined CDDB_FOUND || defined MUSICBRAINZ5_FOUND
              #include "devices/audiocdsettings.h"
              #endif
              #include "shortcutssettingspage.h"
              #include "scrobbling/scrobblingsettings.h"
              #include "apikeyssettings.h"
              #include "support/monoicon.h"
              #include <QDesktopWidget>
              #include <QTimer>
              
              static int iCount=0;
              
              int PreferencesDialog::instanceCount()
              {
                  return iCount;
              }
              
              PreferencesDialog::PreferencesDialog(QWidget *parent)
                  : ConfigDialog(parent, "PreferencesDialog")
              {
                  iCount++;
                  server = new ServerSettings(this);
                  playback = new PlaybackSettings(this);
                  interface = new InterfaceSettings(this);
                  context = new ContextSettings(this);
                  cache = new CacheSettings(this);
                  scrobbling = new ScrobblingSettings(this);
                  custom = new CustomActionsSettings(this);
                  apiKeys = new ApiKeysSettings(this);
                  server->load();
                  playback->load();
                  interface->load();
                  context->load();
                  scrobbling->load();
                  custom->load();
                  QColor iconColor = Utils::clampColor(palette().text().color());
                  addPage(QLatin1String("collection"), server, tr("Collection"), MonoIcon::icon(FontAwesome::music, iconColor), tr("Collection Settings"));
                  addPage(QLatin1String("playback"), playback, tr("Playback"), MonoIcon::icon(FontAwesome::volumeup, iconColor), tr("Playback Settings"));
                  addPage(QLatin1String("interface"), interface, tr("Interface"), MonoIcon::icon(FontAwesome::sliders, iconColor), tr("Interface Settings"));
                  addPage(QLatin1String("info"), context, tr("Info"), MonoIcon::icon(FontAwesome::infocircle, iconColor), tr("Info View Settings"));
                  addPage(QLatin1String("scrobbling"), scrobbling, tr("Scrobbling"), MonoIcon::icon(FontAwesome::lastfm, iconColor), tr("Scrobbling Settings"));
                  #if defined CDDB_FOUND || defined MUSICBRAINZ5_FOUND
                  audiocd = new AudioCdSettings(0);
                  audiocd->load();
                  addPage(QLatin1String("cd"), audiocd, tr("Audio CD"), Icons::self()->albumMonoIcon, tr("Audio CD Settings"));
                  #endif
                  #ifdef ENABLE_PROXY_CONFIG
                  proxy = new ProxySettings(0);
                  proxy->load();
                  addPage(QLatin1String("proxy"), proxy, tr("Proxy"), MonoIcon::icon(FontAwesome::globe, iconColor), tr("Proxy Settings"));
                  #endif
                  shortcuts = new ShortcutsSettingsPage(nullptr);
                  addPage(QLatin1String("shortcuts"), shortcuts, tr("Shortcuts"), MonoIcon::icon(FontAwesome::keyboardo, iconColor), tr("Keyboard Shortcut Settings"));
                  shortcuts->load();
                  addPage(QLatin1String("cache"), cache, tr("Cache"), MonoIcon::icon(FontAwesome::foldero, iconColor), tr("Cached Items"));
                  addPage(QLatin1String("custom"), custom, tr("Custom Actions"), MonoIcon::icon(FontAwesome::rocket, iconColor), tr("Custom Actions"));
                  addPage(QLatin1String("apikeys"), apiKeys, tr("Service Keys"), MonoIcon::icon(FontAwesome::key, iconColor), tr("Service API Keys"));
                  #ifdef Q_OS_MAC
                  setCaption(tr("Cantata Preferences"));
                  setMinimumWidth(800);
                  #else
                  setCaption(tr("Configure"));
                  #endif
                  setAttribute(Qt::WA_DeleteOnClose);
                  setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
                  setCurrentPage(QLatin1String("collection"));
              }
              
              PreferencesDialog::~PreferencesDialog()
              {
                  iCount--;
              }
              
              void PreferencesDialog::showPage(const QString &page)
              {
                  QStringList parts=page.split(QLatin1Char(':'));
                  if (setCurrentPage(parts.at(0))) {
                      if (parts.count()>1) {
                          QWidget *cur=getPage(parts.at(0));
                          if (qobject_cast<InterfaceSettings *>(cur)) {
                              static_cast<InterfaceSettings *>(cur)->showPage(parts.at(1));
                          }
                      }
                  }
                  Utils::raiseWindow(this);
              }
              
              void PreferencesDialog::writeSettings()
              {
                  // *Must* save server settings first, so that MPD settings go to the correct instance!
                  server->save();
                  playback->save();
                  interface->save();
                  #ifdef ENABLE_PROXY_CONFIG
                  proxy->save();
                  #endif
                  shortcuts->save();
                  #if defined CDDB_FOUND || defined MUSICBRAINZ5_FOUND
                  audiocd->save();
                  #endif
                  context->save();
                  scrobbling->save();
                  custom->save();
                  apiKeys->save();
                  Settings::self()->save();
                  emit settingsSaved();
              }
              
              void PreferencesDialog::save()
              {
                  writeSettings();
              }
              
              void PreferencesDialog::cancel()
              {
                  server->cancel();
              }
              
              #include "moc_preferencesdialog.cpp"
              
              
              F 1 Reply Last reply 15 May 2022, 07:01
              0
              • N Offline
                N Offline
                Nuakount
                wrote on 13 May 2022, 19:51 last edited by
                #7

                Also wondering if certain env variables might affect it, but not familiar enough ...

                1 Reply Last reply
                0
                • J JonB
                  13 May 2022, 14:43

                  @Nuakount
                  These are reasonable, specific questions --- good! :)

                  I'm afraid I am not the person to answer these, but hopefully someone else will soon/in due course.

                  was hoping to add some screenshots, but don't see option to attach local files. I can upload and link if you want

                  You should be able to. On the "toolbar" above where you type in there should be a Picture button and an Upload Image button. The former is for a link to an external URL if you have it somewhere externally, the latter should prompt you to upload a local image file. Unless these are denied to newcomers, but I don't think so.

                  N Offline
                  N Offline
                  Nuakount
                  wrote on 15 May 2022, 02:45 last edited by
                  #8

                  @JonB
                  So - what do you think? Is it pretty typical that there would be no response for a few days, or is it likely that no one's interested?

                  J 1 Reply Last reply 15 May 2022, 06:43
                  0
                  • N Nuakount
                    15 May 2022, 02:45

                    @JonB
                    So - what do you think? Is it pretty typical that there would be no response for a few days, or is it likely that no one's interested?

                    J Offline
                    J Offline
                    JonB
                    wrote on 15 May 2022, 06:43 last edited by
                    #9

                    @Nuakount
                    Sorry, probably nobody has anything to offer. You are talking about existing code which is large, somebody would probably have to understand the whole code. For example, I see nothing in the "preferences" code you pasted which would have anything to do with size or margins. If you (choose to) launch with "QT_SCALE_FACTOR=3" it is hardly surprising that, say, a dialog is way too large. "I built v2.4, because newer releases require qt>5.11, but I have 5.6": well, you need to use the newest version of the software, and even Qt 5.11 is old, certainly 5.6 is very old.

                    1 Reply Last reply
                    2
                    • N Nuakount
                      13 May 2022, 16:33

                      preferencesdialog.cpp:

                      
                       * Cantata
                       *
                       * Copyright (c) 2011-2020 Craig Drummond <craig.p.drummond@gmail.com>
                       *
                       * ----
                       *
                       * This program is free software; you can redistribute it and/or modify
                       * it under the terms of the GNU General Public License as published by
                       * the Free Software Foundation; either version 2 of the License, or
                       * (at your option) any later version.
                       *
                       * This program is distributed in the hope that it will be useful,
                       * but WITHOUT ANY WARRANTY; without even the implied warranty of
                       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
                       * General Public License for more details.
                       *
                       * You should have received a copy of the GNU General Public License
                       * along with this program; see the file COPYING.  If not, write to
                       * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
                       * Boston, MA 02110-1301, USA.
                       */
                      
                      #include "preferencesdialog.h"
                      #include "settings.h"
                      #include "widgets/icons.h"
                      #include "interfacesettings.h"
                      #include "serversettings.h"
                      #include "playbacksettings.h"
                      #include "context/contextsettings.h"
                      #include "cachesettings.h"
                      #include "customactionssettings.h"
                      #include "mpd-interface/mpdconnection.h"
                      #ifdef ENABLE_PROXY_CONFIG
                      #include "network/proxysettings.h"
                      #endif
                      #include "shortcutssettingspage.h"
                      #if defined CDDB_FOUND || defined MUSICBRAINZ5_FOUND
                      #include "devices/audiocdsettings.h"
                      #endif
                      #include "shortcutssettingspage.h"
                      #include "scrobbling/scrobblingsettings.h"
                      #include "apikeyssettings.h"
                      #include "support/monoicon.h"
                      #include <QDesktopWidget>
                      #include <QTimer>
                      
                      static int iCount=0;
                      
                      int PreferencesDialog::instanceCount()
                      {
                          return iCount;
                      }
                      
                      PreferencesDialog::PreferencesDialog(QWidget *parent)
                          : ConfigDialog(parent, "PreferencesDialog")
                      {
                          iCount++;
                          server = new ServerSettings(this);
                          playback = new PlaybackSettings(this);
                          interface = new InterfaceSettings(this);
                          context = new ContextSettings(this);
                          cache = new CacheSettings(this);
                          scrobbling = new ScrobblingSettings(this);
                          custom = new CustomActionsSettings(this);
                          apiKeys = new ApiKeysSettings(this);
                          server->load();
                          playback->load();
                          interface->load();
                          context->load();
                          scrobbling->load();
                          custom->load();
                          QColor iconColor = Utils::clampColor(palette().text().color());
                          addPage(QLatin1String("collection"), server, tr("Collection"), MonoIcon::icon(FontAwesome::music, iconColor), tr("Collection Settings"));
                          addPage(QLatin1String("playback"), playback, tr("Playback"), MonoIcon::icon(FontAwesome::volumeup, iconColor), tr("Playback Settings"));
                          addPage(QLatin1String("interface"), interface, tr("Interface"), MonoIcon::icon(FontAwesome::sliders, iconColor), tr("Interface Settings"));
                          addPage(QLatin1String("info"), context, tr("Info"), MonoIcon::icon(FontAwesome::infocircle, iconColor), tr("Info View Settings"));
                          addPage(QLatin1String("scrobbling"), scrobbling, tr("Scrobbling"), MonoIcon::icon(FontAwesome::lastfm, iconColor), tr("Scrobbling Settings"));
                          #if defined CDDB_FOUND || defined MUSICBRAINZ5_FOUND
                          audiocd = new AudioCdSettings(0);
                          audiocd->load();
                          addPage(QLatin1String("cd"), audiocd, tr("Audio CD"), Icons::self()->albumMonoIcon, tr("Audio CD Settings"));
                          #endif
                          #ifdef ENABLE_PROXY_CONFIG
                          proxy = new ProxySettings(0);
                          proxy->load();
                          addPage(QLatin1String("proxy"), proxy, tr("Proxy"), MonoIcon::icon(FontAwesome::globe, iconColor), tr("Proxy Settings"));
                          #endif
                          shortcuts = new ShortcutsSettingsPage(nullptr);
                          addPage(QLatin1String("shortcuts"), shortcuts, tr("Shortcuts"), MonoIcon::icon(FontAwesome::keyboardo, iconColor), tr("Keyboard Shortcut Settings"));
                          shortcuts->load();
                          addPage(QLatin1String("cache"), cache, tr("Cache"), MonoIcon::icon(FontAwesome::foldero, iconColor), tr("Cached Items"));
                          addPage(QLatin1String("custom"), custom, tr("Custom Actions"), MonoIcon::icon(FontAwesome::rocket, iconColor), tr("Custom Actions"));
                          addPage(QLatin1String("apikeys"), apiKeys, tr("Service Keys"), MonoIcon::icon(FontAwesome::key, iconColor), tr("Service API Keys"));
                          #ifdef Q_OS_MAC
                          setCaption(tr("Cantata Preferences"));
                          setMinimumWidth(800);
                          #else
                          setCaption(tr("Configure"));
                          #endif
                          setAttribute(Qt::WA_DeleteOnClose);
                          setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
                          setCurrentPage(QLatin1String("collection"));
                      }
                      
                      PreferencesDialog::~PreferencesDialog()
                      {
                          iCount--;
                      }
                      
                      void PreferencesDialog::showPage(const QString &page)
                      {
                          QStringList parts=page.split(QLatin1Char(':'));
                          if (setCurrentPage(parts.at(0))) {
                              if (parts.count()>1) {
                                  QWidget *cur=getPage(parts.at(0));
                                  if (qobject_cast<InterfaceSettings *>(cur)) {
                                      static_cast<InterfaceSettings *>(cur)->showPage(parts.at(1));
                                  }
                              }
                          }
                          Utils::raiseWindow(this);
                      }
                      
                      void PreferencesDialog::writeSettings()
                      {
                          // *Must* save server settings first, so that MPD settings go to the correct instance!
                          server->save();
                          playback->save();
                          interface->save();
                          #ifdef ENABLE_PROXY_CONFIG
                          proxy->save();
                          #endif
                          shortcuts->save();
                          #if defined CDDB_FOUND || defined MUSICBRAINZ5_FOUND
                          audiocd->save();
                          #endif
                          context->save();
                          scrobbling->save();
                          custom->save();
                          apiKeys->save();
                          Settings::self()->save();
                          emit settingsSaved();
                      }
                      
                      void PreferencesDialog::save()
                      {
                          writeSettings();
                      }
                      
                      void PreferencesDialog::cancel()
                      {
                          server->cancel();
                      }
                      
                      #include "moc_preferencesdialog.cpp"
                      
                      
                      F Offline
                      F Offline
                      fred11
                      Banned
                      wrote on 15 May 2022, 07:01 last edited by
                      #10
                      This post is deleted!
                      1 Reply Last reply
                      0
                      • N Offline
                        N Offline
                        Nuakount
                        wrote on 20 May 2022, 17:37 last edited by
                        #11

                        Ok, how about this - Anybody know a way I can add code or set env to enable rotation, (portrait/landscape, or...). As it is, the qt apps don't respond to phone sensors, but are fixes...

                        1 Reply Last reply
                        0

                        6/11

                        13 May 2022, 16:33

                        • Login

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