Issue
Please picture: There is a MainWindow have a dockwidget.
The dockwidget have a QTextEdit
object.
Dockwidgets can take off from the attached window and be moved to anywhere.
When I edit the QTextEdit,I call it by focusWidget()
method from QMainWindow
area without floating the dockwidget.
<__main__.xxxxxxxxxx object at 0x000002815D638388>
This address is a kind of QTextEdit (xxxxxxxxxx because it is my Subclass).
During floating the dockWidget,I call it by focusWidget()
,
<PySide.QtGui.QTabBar object at 0x000002816A206C88>
I would like to get the same widget in spite of the dockwidget's conditions.
Solution
Please use QtGui.QApplication.focusWidget()
you can get the current focusWidget from anywhere.
Please ,see also here
QtGui.QApplication.focusWidget()
:added solution
The above method and solution was not good.
you may globalize the dockwidget's mainwindow ,(f-ex g_win)
global g_win
g_win = mainwindow()
and,override the widget's focusInEvent()
def focusInEvent(self,event):
## you can get the address anywhere
g_win.current_widget = self
return TheWidget.focusInEvent(self,event)
and you can call g_win.current_widget
and get it anywhere.
after that,you can adopt your codes to the widget.
Please pay attention to usage global statement.
but the mainwindow is probably used as if it were global class.
this is the most useful,i think.
Answered By - Haru
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.