how to get the QWidget pointer of the workspace area?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

how to get the QWidget pointer of the workspace area?

speedinghong
from DesktopServices::getMainWidget() ,i can get the Qwidget for the main application window,but  failed to find a way to get just the workspace area
Reply | Threaded
Open this post in threaded view
|

Re: how to get the QWidget pointer of the workspace area?

dadkins
Administrator
What is it that you are trying to do? Assuming that you want the
Workspace (i.e.: the gray area that holds all of the spatial data
views), you can probably do something like this (NULL checks etc.
omitted). I did not test it so YMMV:

Window* pWindow =
Service<DesktopServices>()->getCurrentWorkspaceWindow();
QWidget* pChild = pWindow->getWidget();
QWidget* pWidget = pChild->parent();

Please let us know if this helped.

Thanks,
Dustan

-----Original Message-----
From: speedinghong [mailto:[hidden email]]
Sent: Monday, June 11, 2012 10:06 PM
To: [hidden email]
Subject: [Opticks-devs] how to get the QWidget pointer of the workspace
area?

from DesktopServices::getMainWidget() ,i can get the Qwidget for the
main
application window,but  failed to find a way to get just the workspace
area

--
View this message in context:
http://opticks-devs.2021163.n4.nabble.com/how-to-get-the-QWidget-pointer
-of-the-workspace-area-tp4652687.html
Sent from the opticks-devs mailing list archive at Nabble.com.

------------------------------------------------------------------------
------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
will include endpoint security, mobile security and the latest in
malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs



This message and any enclosures are intended only for the addressee.  Please

notify the sender by email if you are not the intended recipient.  If you are

not the intended recipient, you may not use, copy, disclose, or distribute this

message or its contents or enclosures to any other person and any such actions

may be unlawful.  Ball reserves the right to monitor and review all messages

and enclosures sent to or from this email address.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs
Reply | Threaded
Open this post in threaded view
|

Re: how to get the QWidget pointer of the workspace area?

speedinghong
i want to get the gray area widget that holds all of the workspacewindows,not the specified some window.
i want to add some control on that,is it possible?
ps.can dockwindow be maximized like workspacewindow?even by handling the resize event?
Reply | Threaded
Open this post in threaded view
|

Re: how to get the QWidget pointer of the workspacearea?

dadkins
Administrator
I believe that the code I sent earlier will give you access to the gray
workspace area. If you cast it to a QMdiArea, you should be able to use
it. Like I said though, I haven't specifically tried to do so.

As for dock windows, no, there is no easy way to maximize them. You
could try setting the window flags on the widget to try to trick Qt into
adding a maximize button, but I wouldn't recommend it. If you have
something you would like to maximize, try putting the widget into
something other than a dock window.

Thanks,
Dustan

-----Original Message-----
From: speedinghong [mailto:[hidden email]]
Sent: Tuesday, June 12, 2012 6:34 AM
To: [hidden email]
Subject: Re: [Opticks-devs] how to get the QWidget pointer of the
workspacearea?

i want to get the gray area widget that holds all of the
workspacewindows,not
the specified some window.
i want to add some control on that,is it possible?
ps.can dockwindow be maximized like workspacewindow?even by handling the
resize event?

--
View this message in context:
http://opticks-devs.2021163.n4.nabble.com/how-to-get-the-QWidget-pointer
-of-the-workspace-area-tp4652687p4652689.html
Sent from the opticks-devs mailing list archive at Nabble.com.

------------------------------------------------------------------------
------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
will include endpoint security, mobile security and the latest in
malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs



This message and any enclosures are intended only for the addressee.  Please

notify the sender by email if you are not the intended recipient.  If you are

not the intended recipient, you may not use, copy, disclose, or distribute this

message or its contents or enclosures to any other person and any such actions

may be unlawful.  Ball reserves the right to monitor and review all messages

and enclosures sent to or from this email address.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs
Reply | Threaded
Open this post in threaded view
|

Re: how to get the QWidget pointer of the workspacearea?

speedinghong
ok,then i will consider using workspacewindow.
as for the way you mentioned,i have a puzzle,when i open opticks,there are no CurrentWorkspaceWindow(),seems i cannot rely on that way.i don't know whether i explain clearly,what i want is the widget that stay behind all the workspacewindows(no matter workspacewindows exist or not)
Reply | Threaded
Open this post in threaded view
|

Re: how to get the QWidget pointer of theworkspacearea?

dadkins
Administrator
I understand. Yes, my method will not work if there are no active
workspace windows. You could also try to iterate over the children of
getMainWidget() and take the first one that can successfully be
dynamic_cast to a QMdiArea. That should work as well.

--Dustan

-----Original Message-----
From: speedinghong [mailto:[hidden email]]
Sent: Tuesday, June 12, 2012 6:55 AM
To: [hidden email]
Subject: Re: [Opticks-devs] how to get the QWidget pointer of
theworkspacearea?

ok,then i will consider using workspacewindow.
as for the way you mentioned,i have a puzzle,when i open opticks,there
are
no CurrentWorkspaceWindow(),seems i cannot rely on that way.i don't know
whether i explain clearly,what i want is the widget that stay behind all
the
workspacewindows(no matter workspacewindows exist or not)

--
View this message in context:
http://opticks-devs.2021163.n4.nabble.com/how-to-get-the-QWidget-pointer
-of-the-workspace-area-tp4652687p4652691.html
Sent from the opticks-devs mailing list archive at Nabble.com.

------------------------------------------------------------------------
------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
will include endpoint security, mobile security and the latest in
malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs



This message and any enclosures are intended only for the addressee.  Please

notify the sender by email if you are not the intended recipient.  If you are

not the intended recipient, you may not use, copy, disclose, or distribute this

message or its contents or enclosures to any other person and any such actions

may be unlawful.  Ball reserves the right to monitor and review all messages

and enclosures sent to or from this email address.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs
Reply | Threaded
Open this post in threaded view
|

Re: how to get the QWidget pointer of theworkspacearea?

speedinghong
all right,i will try now ~thanks
if i want to add a picture on toolbar,do you have any advice?
Reply | Threaded
Open this post in threaded view
|

Re: how to get the QWidget pointer oftheworkspacearea?

dadkins
Administrator
Look at MouseModePlugIn and PlotManager inside PlugInSamplerQt or at the
Spectral Processing Extension for several examples. You will want to be
familiar with QIcon (and perhaps QPixmap). Feel free to use any of the
standard Opticks icons, all of which should be available as resources
(e.g.: QIcon(":/icons/Delete")). You can browse the icons used in
Opticks by going to [1]. The mapping from file name to resource name is
at [2].

--Dustan

[1]
https://opticks.svn.sourceforge.net/svnroot/opticks/trunk/future/Code/ap
plication/Gui/res/icons/
[2]
https://opticks.svn.sourceforge.net/svnroot/opticks/trunk/future/Code/ap
plication/Gui/res/Application.qrc


-----Original Message-----
From: speedinghong [mailto:[hidden email]]
Sent: Tuesday, June 12, 2012 7:06 AM
To: [hidden email]
Subject: Re: [Opticks-devs] how to get the QWidget pointer
oftheworkspacearea?

all right,i will try now ~thanks
if i want to add a picture on toolbar,do you have any advice?

--
View this message in context:
http://opticks-devs.2021163.n4.nabble.com/how-to-get-the-QWidget-pointer
-of-the-workspace-area-tp4652687p4652693.html
Sent from the opticks-devs mailing list archive at Nabble.com.

------------------------------------------------------------------------
------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
will include endpoint security, mobile security and the latest in
malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs



This message and any enclosures are intended only for the addressee.  Please

notify the sender by email if you are not the intended recipient.  If you are

not the intended recipient, you may not use, copy, disclose, or distribute this

message or its contents or enclosures to any other person and any such actions

may be unlawful.  Ball reserves the right to monitor and review all messages

and enclosures sent to or from this email address.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs
Reply | Threaded
Open this post in threaded view
|

Re: how to get the QWidget pointer oftheworkspacearea?

tclarke
Administrator
In reply to this post by dadkins
This is the only way to get at the workspace. It's not normally
something we make available to plug-ins so there's no Opticks API method
to access this. getMainWidget() give you the main application window.
The widget you are looking for is the Workspace which is a subclass of
QMdiArea. It's not a direct child of the application window. There is a
QFrame child of the application window which contains the Workspace so
you need to do a nested iteration. Luckily, Qt has a function to do a
recursive child search. You'd do something like:

QWidget* pAppWindow = Service<DesktopServices>()->getMainWidget();
QList<QMdiArea*>
workspace(pAppWindow->findChildren<QMdiArea*>(QString()));
if (!pWokspace->isEmpty())
{
   // found the QMdiArea. There should only be one in the entire app so
the following is a sanity check
   VERIFY(pWorkspace->size() == 1);
}

-----Original Message-----
From: Adkins, Dustan [mailto:[hidden email]]
Sent: Tuesday, June 12, 2012 6:57 AM
To: [hidden email]
Subject: Re: [Opticks-devs] how to get the QWidget pointer
oftheworkspacearea?

I understand. Yes, my method will not work if there are no active
workspace windows. You could also try to iterate over the children of
getMainWidget() and take the first one that can successfully be
dynamic_cast to a QMdiArea. That should work as well.

--Dustan

-----Original Message-----
From: speedinghong [mailto:[hidden email]]
Sent: Tuesday, June 12, 2012 6:55 AM
To: [hidden email]
Subject: Re: [Opticks-devs] how to get the QWidget pointer of
theworkspacearea?

ok,then i will consider using workspacewindow.
as for the way you mentioned,i have a puzzle,when i open opticks,there
are
no CurrentWorkspaceWindow(),seems i cannot rely on that way.i don't know
whether i explain clearly,what i want is the widget that stay behind all
the
workspacewindows(no matter workspacewindows exist or not)

--
View this message in context:
http://opticks-devs.2021163.n4.nabble.com/how-to-get-the-QWidget-pointer
-of-the-workspace-area-tp4652687p4652691.html
Sent from the opticks-devs mailing list archive at Nabble.com.

------------------------------------------------------------------------
------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
will include endpoint security, mobile security and the latest in
malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs



This message and any enclosures are intended only for the addressee.
Please

notify the sender by email if you are not the intended recipient.  If
you are

not the intended recipient, you may not use, copy, disclose, or
distribute this

message or its contents or enclosures to any other person and any such
actions

may be unlawful.  Ball reserves the right to monitor and review all
messages

and enclosures sent to or from this email address.

------------------------------------------------------------------------
------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
will include endpoint security, mobile security and the latest in
malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs



This message and any enclosures are intended only for the addressee.  Please

notify the sender by email if you are not the intended recipient.  If you are

not the intended recipient, you may not use, copy, disclose, or distribute this

message or its contents or enclosures to any other person and any such actions

may be unlawful.  Ball reserves the right to monitor and review all messages

and enclosures sent to or from this email address.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs
Reply | Threaded
Open this post in threaded view
|

Re: how to get the QWidget pointer oftheworkspacearea?

speedinghong
the pWorkspace i got is empty...don't know why

QWidget* pAppWindow = pDesktop->getMainWidget();
QList<QMdiArea*> pWorkspace = (pAppWindow->findChildren<QMdiArea*>(QString()));
bool bflag = pWorkspace.isEmpty();
the bflag is true
Reply | Threaded
Open this post in threaded view
|

Re: how to get the QWidget pointeroftheworkspacearea?

dadkins
Administrator
Do you have any workspace windows open?

-----Original Message-----
From: speedinghong [mailto:[hidden email]]
Sent: Tuesday, June 12, 2012 10:00 AM
To: [hidden email]
Subject: Re: [Opticks-devs] how to get the QWidget
pointeroftheworkspacearea?

the pWorkspace i got is empty...don't know why

QWidget* pAppWindow = pDesktop->getMainWidget();
QList<QMdiArea*> pWorkspace =
(pAppWindow->findChildren<QMdiArea*>(QString()));
bool bflag = pWorkspace.isEmpty();
the bflag is true

--
View this message in context:
http://opticks-devs.2021163.n4.nabble.com/how-to-get-the-QWidget-pointer
-of-the-workspace-area-tp4652687p4652696.html
Sent from the opticks-devs mailing list archive at Nabble.com.

------------------------------------------------------------------------
------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
will include endpoint security, mobile security and the latest in
malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs



This message and any enclosures are intended only for the addressee.  Please

notify the sender by email if you are not the intended recipient.  If you are

not the intended recipient, you may not use, copy, disclose, or distribute this

message or its contents or enclosures to any other person and any such actions

may be unlawful.  Ball reserves the right to monitor and review all messages

and enclosures sent to or from this email address.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs
Reply | Threaded
Open this post in threaded view
|

Re: how to get the QWidget pointeroftheworkspacearea?

tclarke
Administrator
In reply to this post by speedinghong
You can try doing a findChildren() on QFrame, iterating the result and
checking their children for QMdiArea.

-----Original Message-----
From: speedinghong [mailto:[hidden email]]
Sent: Tuesday, June 12, 2012 10:00 AM
To: [hidden email]
Subject: Re: [Opticks-devs] how to get the QWidget
pointeroftheworkspacearea?

the pWorkspace i got is empty...don't know why

QWidget* pAppWindow = pDesktop->getMainWidget();
QList<QMdiArea*> pWorkspace =
(pAppWindow->findChildren<QMdiArea*>(QString()));
bool bflag = pWorkspace.isEmpty();
the bflag is true

--
View this message in context:
http://opticks-devs.2021163.n4.nabble.com/how-to-get-the-QWidget-pointer
-of-the-workspace-area-tp4652687p4652696.html
Sent from the opticks-devs mailing list archive at Nabble.com.

------------------------------------------------------------------------
------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
will include endpoint security, mobile security and the latest in
malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs



This message and any enclosures are intended only for the addressee.  Please

notify the sender by email if you are not the intended recipient.  If you are

not the intended recipient, you may not use, copy, disclose, or distribute this

message or its contents or enclosures to any other person and any such actions

may be unlawful.  Ball reserves the right to monitor and review all messages

and enclosures sent to or from this email address.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs
Reply | Threaded
Open this post in threaded view
|

Re: how to get the QWidget pointeroftheworkspacearea?

speedinghong
In reply to this post by dadkins
i have tried to open a image before,but it is still empty