Qt4 GUI in Ruby for Sketchup plugin's
-
@jim said:
Just wanted to point out wxSU.
Didn't SU4Thea use that at some point - and it caused conflicts and issues. Messed around with lots of stuff, even attached hidden windows to the SketchUp window etc...? Or was that something else?
-
@jim said:
Just wanted to point out wxSU. Similar idea to yours, but uses wxWindows. Perhaps there is some ideas that could be applied to Qt4.
That is a very good idea - will have a look
-
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 viaWin32API
?? -
@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 viaWin32API
??Yes it can.
-
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/QtcoreAs 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. -
@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 moduleKernel
, which is "mixed into" classObject
, using the C-side of theinclude
method.Therefore... since ALL objects in Ruby are subclasses of
Object
, EVERY object's pedigree will containObject
andKernel
. You can see this with theancestors()
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
andKernel.load
methods.. and understand howrequire
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.
-
@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/QtcoreShould 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.
-
@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
-
@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've found this project....what do u think??
-
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 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?
Advertisement