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. what qwidget subclass?
Qt 6.11 is out! See what's new in the release blog

what qwidget subclass?

Scheduled Pinned Locked Moved Solved General and Desktop
24 Posts 4 Posters 10.7k Views 3 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.
  • U user4592357

    @mrjj

    no i don't need to show a dialog, i just need to go and grab the image located in the user-specified path

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

    @user4592357
    Ok, i see no reason it should not work if the paths are fully qualified and
    valid.

    I would test that
    qDebug() << "loading: " pixmap.load(iconPath);
    says true
    also i would try with

    #include <QFileInfo>
    
    bool fileExists(QString path) {
        QFileInfo check_file(path);
        // check if file exists and if yes: Is it really a file and no directory?
        return check_file.exists() && check_file.isFile();
    }
    
    and check iconPath where u try to load the image.
    

    Also where does icon-full-path come from ?
    Is it in the app or do you load from text file ?

    1 Reply Last reply
    1
    • U Offline
      U Offline
      user4592357
      wrote on last edited by
      #11

      thanks. i'll read a text file for that, but why does that matter?

      mrjjM 1 Reply Last reply
      0
      • U user4592357

        thanks. i'll read a text file for that, but why does that matter?

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

        @user4592357
        Well if inside the app you must escape

        c:\\xxx\\cyy\\
        

        But that is not valid if from text file so just asking to try to guess reason that is not shown :)

        U 1 Reply Last reply
        1
        • mrjjM mrjj

          @user4592357
          Well if inside the app you must escape

          c:\\xxx\\cyy\\
          

          But that is not valid if from text file so just asking to try to guess reason that is not shown :)

          U Offline
          U Offline
          user4592357
          wrote on last edited by
          #13

          @mrjj

          QFile::exists() gives false when i use a full path for the image (like, C:\Users\user\image.png). but the file sure exists. i've tried using \\ instead of \, also / but not much success. with resource system, however, everything is okay

          mrjjM 1 Reply Last reply
          0
          • U user4592357

            @mrjj

            QFile::exists() gives false when i use a full path for the image (like, C:\Users\user\image.png). but the file sure exists. i've tried using \\ instead of \, also / but not much success. with resource system, however, everything is okay

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

            @user4592357
            if you take one of the paths from the file
            and start paintbrush, select file->open
            and paste the path into the filename area. and then press open.
            will it then open ?

            it sounds really, really wrong if QFile::exists() says false.

            U 1 Reply Last reply
            0
            • mrjjM mrjj

              @user4592357
              if you take one of the paths from the file
              and start paintbrush, select file->open
              and paste the path into the filename area. and then press open.
              will it then open ?

              it sounds really, really wrong if QFile::exists() says false.

              U Offline
              U Offline
              user4592357
              wrote on last edited by
              #15

              @mrjj

              yes it opens.

              this is weird, really.
              this works:

              QFileInfo file("C:\Users\user\image.png");
              setIcon(file.filePath());
              

              but when i get the SAME line from a file and set the icon to it... it doesn't work

              mrjjM 1 Reply Last reply
              0
              • U user4592357

                @mrjj

                yes it opens.

                this is weird, really.
                this works:

                QFileInfo file("C:\Users\user\image.png");
                setIcon(file.filePath());
                

                but when i get the SAME line from a file and set the icon to it... it doesn't work

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

                Hi
                Did you try to qDebug() << file.filePath();
                to see if anything still 100% like the one in file?

                U 1 Reply Last reply
                1
                • mrjjM mrjj

                  Hi
                  Did you try to qDebug() << file.filePath();
                  to see if anything still 100% like the one in file?

                  U Offline
                  U Offline
                  user4592357
                  wrote on last edited by
                  #17

                  @mrjj

                  yes they're the same, actually i've copied them

                  mrjjM 1 Reply Last reply
                  0
                  • U user4592357

                    @mrjj

                    yes they're the same, actually i've copied them

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

                    @user4592357
                    Really cannot guess then.
                    If path in text file truely are valid syntax, it should just work.
                    and you are 100% sure you escape it ?
                    ( which is needed when inside the code, but from text file)

                    setIcon("C:\\Users\\user\\image.png");
                    
                    
                    U 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @user4592357
                      Really cannot guess then.
                      If path in text file truely are valid syntax, it should just work.
                      and you are 100% sure you escape it ?
                      ( which is needed when inside the code, but from text file)

                      setIcon("C:\\Users\\user\\image.png");
                      
                      
                      U Offline
                      U Offline
                      user4592357
                      wrote on last edited by
                      #19

                      @mrjj

                      yes i've tried everything

                      okay, thanks anyways

                      mrjjM 1 Reply Last reply
                      0
                      • U user4592357

                        @mrjj

                        yes i've tried everything

                        okay, thanks anyways

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

                        @user4592357
                        I have done it many times so I do
                        wonder what you do that is
                        different or if it really just is a path issue.

                        U 1 Reply Last reply
                        0
                        • mrjjM mrjj

                          @user4592357
                          I have done it many times so I do
                          wonder what you do that is
                          different or if it really just is a path issue.

                          U Offline
                          U Offline
                          user4592357
                          wrote on last edited by user4592357
                          #21

                          @mrjj

                          it's really just a path

                          i even tried to QDir::toNativeSeparators(). nothing works

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

                            Hi,

                            Since you are using Qt, why not use the Unix notation ? Qt handles the conversion when it calls the related platform specific functions.

                            So it should be C:/Users/user/image.png

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

                            U 1 Reply Last reply
                            0
                            • SGaistS SGaist

                              Hi,

                              Since you are using Qt, why not use the Unix notation ? Qt handles the conversion when it calls the related platform specific functions.

                              So it should be C:/Users/user/image.png

                              U Offline
                              U Offline
                              user4592357
                              wrote on last edited by
                              #23

                              @SGaist

                              i've tried that too, it doesn't work

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

                                Does that file have any permission issues ?
                                Are you 100% sure that it's there ?
                                Are you loading it from your own user account ?
                                Any special char in the path ? i.e is user really the account name ?

                                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
                                1

                                • Login

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