Results 1 to 20 of 27

Thread: Coin3d + Qt: SIGLNALs and SLOTs

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2006
    Location
    Shrewsbury, UK
    Posts
    97
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 11 Times in 11 Posts

    Default Re: Coin3d + Qt: SIGLNALs and SLOTs

    X-man,

    I did see your post earlier, but my first reply got scewed up by a timeout.

    Its not too hard to get references from one window to another. However what I think your trying to do is display the same widget in two containers - and I don't really think thats very sensible. In the windows world your widget will eventually map to a HWND which is unique to a window.

    My original mods for vonCZ were based on making his existing code work with as small changes as possible. Theres are a number of considerations.

    1. The Model class manages both a Coin viewer and its scenegraph - this should really have been split into 2 separate classes.
    2. The coinwidget interacts with a rotation node in the scenegraph. This effectively changes the rotation of the code in world space, not the position of the camera.

    I'd like to get a better understanding of what your tying to achieve, perhaps some screen mock-ups, before making any further suggestions. I would still always ask the core question as well - "Why are you trying to do it this way?".

    Pete

  2. #2
    Join Date
    May 2007
    Location
    Athens, Greece
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    2

    Default Re: Coin3d + Qt: SIGLNALs and SLOTs

    Pete,

    first of all, thanks for the reply. Now, regarding your points...

    1. It make sense; i mean, having them in separate classes - but that should not be a problem for the time being (or is it? if so, any advice on how to change that->creating two classes?)
    2. No problem with that - I now have six (6) spinboxes inside my window.cpp, who alter six rotation nodes inside my model. As for them rotating in real world (not camera), that's exactly what I want them to do.

    Ok, now on to your "why-are-you-doing-that" question...

    From what I understood in your example (correct me if I'm wrong), the application shows a window (created in window.cpp), which includes some widgets (a slider in your case, some spinboxes in mine), one of the widgets being coinwidget, which then (through the coinwidget.cpp) creates a -coin- model, which is also shown (since we have a "show();" near the end of model.cpp).

    Where I want to get - one window with my spinboxes alone, which communicate via slots/signals with certain rotation nodes of the model (via the coinwidget), in order to rotate my model. And then, another window with that model and ALSO a couple of Qt widgets (I'm not sure yet what kind of widgets I will be needing, but lets take for example that I will need some QLCDNumber widgets).

    And here's the problem; in order to connect the spinboxes in window.cpp (the same way you connected the slider), I create a coinwidget = new coinwidget. Just in order to do the slot/signal thing (let's say that I don't even include the "mainLayout->addWidget (coinWidget);" part). So, at that point we have a coinwidget created, with certain rotations altered "dynamically" from some widgets inside the window.cpp, and all these changes can be seen in the created model (because of the "show()" in model.cpp). Now, if I want in my window2.cpp to have that same model shown at (0,0) and have my other widgets (the lcdnumbers) underneath, I don't know how to call that instance. Naturally, if I just go with "addWidget (coinWidget);", it returns that it is undeclared, if I have a "coinwidget2 = new Coinwidget" before, I get a model shown, but it's just a new instance, so any changes I make in my spinboxes, are not trasmitted inside this model. I also tried something like "addWidget (Window::coinWidget)", but I got "illegal reference to non-static member 'Window::coinWidget'" in return.

    Am I going the wrong way here? I'm open to any suggestions, either in terms of general approach or in specific coding instructions.

    Let me know if you need the whole of my code to check it out - i'll .rar it and pass it on.

    Thanks again for your attention, I appreciate it .

    X-man

  3. #3
    Join Date
    Nov 2006
    Location
    Shrewsbury, UK
    Posts
    97
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 11 Times in 11 Posts

    Default Re: Coin3d + Qt: SIGLNALs and SLOTs

    X-man,

    Sorry but I'm at work athe moment so I can't give you a "tested" response, but I can give you something to work on during the day. I can break your problem into two peices

    1. How do I connect the signals and slots.
    2. How do I share a scenegraph.

    The first is relatively straightforward - I'll outline 3 options, but for now I'd recommend the first as it should be the easiest to implement and test.

    a) Alter your Window2 constructor to take a Window pointer, and cache it in a Window2 member variable - perhaps call it "partnerWindow". From the top down in main.cpp you'd see something like
    Qt Code:
    1. Window *window = new Window();
    2. Window2 *window2 = new Window2(window);
    3. window->show();
    4. window2->show();
    To copy to clipboard, switch view to plain text mode 
    Now you can connect public slots and signals between the two windows in your Window2 constructor - or another method.

    b) Connect the signals and slots statically in main.cpp with fully qualified QObject::connect(.....) methods - you have pointers to both objects here.

    c) Build a new proxy "controller" class and use this to sychronise events between the 2 windows.

    The next piece needs some testing, but in essence what you can do is to expose the scenegraph root node in window.cpp/h via a public getSceneGraph() function. In option a) this can be accessed directly from the new classmember (partnerWindow) - in options c) and b) you might need a corresponding setSceneGraph(...) exposed in Window2. Both set/getSceneGraph will actually need to be wrappers for the enclosed Model objects which will also need amending . Now you should be able to set the Window's Model scenegraph as the root node of the Model in Window2 - what happens next I can't tell. I'll try it myself tonight.

    You can post the code to "peter at dolbey dot freeserve dot co dot uk" - with the usual replacements.

    Pete
    Last edited by pdolbey; 22nd May 2007 at 09:28.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.