sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Qt4 GUI in Ruby for Sketchup plugin's

    Scheduled Pinned Locked Moved Developers' Forum
    17 Posts 6 Posters 2.7k Views 6 Watching
    Loading More Posts
    • 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.
    • Dan RathbunD Offline
      Dan Rathbun
      last edited by

      Yes thomthom, WxSU creates an invisible toplevel windowframe around the SketchUp application window, so that Wx messages can bubble up to that window object and be processed. (It changes the SU app window class to be a child of this invisible window.)

      I wonder if this can cause problems for plugins that use EventRelay, or plugins that are searching for window objects using Win API calls via Win32API ??

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        @dan rathbun said:

        I wonder if this can cause problems for plugins that use EventRelay, or plugins that are searching for window objects using Win API calls via Win32API ??

        Yes it can.

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • M Offline
          MOGhouse
          last edited by

          Hi guys - thank you for your input.

          It might be that Dan is right and a complete ruby installation is needed at runtime, but that is not the easy lightweight solution I was hoping for.
          Here is what I was hoping to achieve.

          main.rb cotains

          require 'your_ui.rb'
          

          and

          require 'Qt4'
          

          I want to track down the files/libraries that are sought by

          require 'Qt4'
          

          The files required by Qt4 is placed inside the sketchup tree, maybe in /Resources/Qt/, as standalone dependencies for plugin's.
          Then require the files directly with a path to the files... /Resources/Qt/Qtcore

          As I understand Sketchup runs its own ruby interpreter 1.8.6, and I want the interpreter to run the GUI also.

          Should this work? or is it a really bad idea?

          Sorry, I have a stupid question - I can't get my head around the require.
          When you require 'Sketchup' or 'Qt4' - what actually happens, which files are actually sought? - I sure there is an easy way to track them down, I just can't find it .... πŸ˜•
          Can anyone give me a hint.

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            @moghouse said:

            Sorry, I have a stupid question - I can't get my head around the require.
            When you require 'Sketchup' or 'Qt4' - what actually happens, which files are actually sought?

            The require() method is defined in mixin module Kernel, which is "mixed into" class Object, using the C-side of the include method.

            Therefore... since ALL objects in Ruby are subclasses of Object, EVERY object's pedigree will contain Object and Kernel. You can see this with the ancestors() method. Subclasses inherit their ancestors methods, but can be overridden locally within a class or module, or locally undefined (which is rare.)

            You should read up on the Kernel.require and Kernel.load methods.. and understand how require uses the global arrays $LOAD_PATH (aka $:,) and $LOADED_FEATURES (aka $".)

            Get the Standard Ruby 1.8.6 Reference (CHM) here, or access the online web editions for the Core and Libs.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              @moghouse said:

              The files required by Qt4 is placed inside the sketchup tree, maybe in /Resources/Qt/, as standalone dependencies for plugin's.
              Then require the files directly with a path to the files... /Resources/Qt/Qtcore

              Should this work? or is it a really bad idea?

              Bad idea.

              1) the Resouces path is a application OEM path and should remain "hands off"

              2) it is very difficult to install anything into that path

              Ruby libraries, other than a few win32ole.so and Win32API.so (for historical reasons,) need to stay in the Ruby lib directories. (And even those 2 mentioned here, should stay in the full Ruby install folders, if possible.)

              We just cannot copy all of the Ruby extended library files into the Sketchup plugins folder. It will create havoc.

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                @moghouse said:

                main.rb cotains

                require 'your_ui.rb'
                

                and

                require 'Qt4'
                

                Actually the 'author_subdir/your_ui.rb' file would have statement(s) at or near the top that are:

                require('!loadpaths')
                require('Qt4')
                
                

                See my post: [ Code ] Ruby LOAD PATHs script (Win32) : ver 3.0.1

                πŸ’­

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  @moghouse said:

                  I want to track down the files/libraries that are sought by Qt4

                  I do remember seeing a Ruby script that would go through a file looking for require statements, and search each dependency in turn for their dependancies.

                  It would print out a report. Either was something Rick Wilson wrote, .. or something that disro'd with the Full Ruby install.

                  But cannot locate it now.

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • bomastudioB Offline
                    bomastudio
                    last edited by

                    I've found this project....what do u think??

                    http://visualruby.net/

                    1 Reply Last reply Reply Quote 0
                    • Dan RathbunD Offline
                      Dan Rathbun
                      last edited by

                      It has nothing to do with Qt4, uses GTK+ and should not work under SketchUp Ruby, as is.
                      You should start a new topic just for this (VisualRuby/Glade) subject.

                      I'm not here much anymore.

                      1 Reply Last reply Reply Quote 0
                      • A Offline
                        archonmaster
                        last edited by

                        I also want to use QT for user interface. Is there any examples?
                        I decide to create thread and execute main loop of QT application in this thread.
                        [pre:g779cno0]DWORD WINAPI mainLoop(CONST LPVOID lpParam) {
                        coreDataStruct * data = (coreDataStruct *)lpParam;

                        int argc = 0;
                        char **argv = 0;
                        
                        data->app = new QApplication(argc, argv);
                        data->app->setQuitOnLastWindowClosed(false);
                        data->app->exec();
                        
                        data->active = 0;
                        ExitThread(0);
                        

                        }
                        VALUE cModule_initialize(...) {
                        if (coreData->active == 0) {
                        HANDLE thread = CreateThread(NULL, 0, &mainLoop, (void*)coreData, 0, NULL);
                        coreData->mainThread = thread;
                        coreData->active = 1;
                        return Qtrue;
                        }
                        return Qfalse;
                        }[/pre:g779cno0]
                        Thread is created in function cModule_initialize that should be executed in the begining
                        To create window I have this function:
                        [pre:g779cno0]VALUE cModule_createWin(...) {
                        if (coreData->active == 0) return Qfalse;
                        QDialog *dialog = new QDialog;
                        dialog->show();
                        return Qtrue;
                        }[/pre:g779cno0]
                        Is that correct?

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement