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

UI Builder

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 5 Posters 3.2k Views 2 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.
  • Y Offline
    Y Offline
    YorkCleave
    wrote on last edited by
    #5

    image.png
    Ok I tried your suggestion but then the program doesn't seem to run ?

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

      Please do not post screenshots.
      Since you did not post your code I don't know what you're doing wrong. There are a lot of Qt examples out there on how to use ui files: https://doc.qt.io/qt-6/examples-widgets.html

      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
      0
      • Y Offline
        Y Offline
        YorkCleave
        wrote on last edited by
        #7

        Ok, here is the code for the main function :
        int main(int argc, char *argv[]) {
        QApplication app(argc, argv);

        QFile file("MainMenu.ui");
        file.open(QFile::ReadOnly);
        
        QUiLoader loader;
        QWidget *widget = loader.load(&file);  // Load the UI file dynamically
        file.close();
        
        if (!widget) return -1;
        
        widget->show();
        
        
        ChessBoard board;
        board.show();
        
        return app.exec();
        

        }

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

          Hi,

          You are using a relative path. You ui file is not located in the build folder thus it cannot be loaded.

          You should add proper error checking to your QFile code. It would have caught the issue.

          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
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #9

            I still don't know what you're trying to achieve by loading a ui file directly and then simply showing it. You should also check if the file could be opened successfully if you want to stay with the loading of the ui file.
            Use a debugger to see where exactly it is crashing. i would guess somewhere inside your ChessBoard class.

            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
            1
            • Y Offline
              Y Offline
              YorkCleave
              wrote on last edited by
              #10

              Thanks for the help. The problem was the relative path. It is working now.

              1 Reply Last reply
              0
              • Y Offline
                Y Offline
                YorkCleave
                wrote on last edited by
                #11

                Ok the next issue has arisen.
                When I try and create a signal on the "New Standard Game", it says no documents matching ui_MainMenu.h could be found ?

                Pl45m4P jsulmJ 2 Replies Last reply
                0
                • Y YorkCleave

                  Ok the next issue has arisen.
                  When I try and create a signal on the "New Standard Game", it says no documents matching ui_MainMenu.h could be found ?

                  Pl45m4P Offline
                  Pl45m4P Offline
                  Pl45m4
                  wrote on last edited by
                  #12

                  @YorkCleave said in UI Builder:

                  When I try and create a signal on the "New Standard Game", it says no documents matching ui_MainMenu.h could be found ?

                  We don't know what "New Standard Game" means in your case and we can't see what you are doing.
                  ui_MainMenu.h is the translated UI Header, which should have nothing to do with Signals & Slots, unless you are connecting to the UI of another class, which is not a good way and might lead to issue sooner or later.


                  If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                  ~E. W. Dijkstra

                  1 Reply Last reply
                  0
                  • Y YorkCleave

                    Ok the next issue has arisen.
                    When I try and create a signal on the "New Standard Game", it says no documents matching ui_MainMenu.h could be found ?

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #13

                    @YorkCleave Is there a reason why you're using QUiLoader?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    1
                    • Y Offline
                      Y Offline
                      YorkCleave
                      wrote on last edited by
                      #14

                      Ok. is it ok if I post a screenshot of MainMenu here ?

                      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