Mananing multiples Uis or using QGraphicsview ?
-
Hello, i'm working on an application and i need to create a second window. So i created a second Ui File, with its cpp class and header. the thing is, i want something in this window to call a function that belongs to the first window, but i havent managed to do this. it looks likes its really difficult to manage multiple ui files. To be more precise, the second window the second window makes a signal with an argument, and i need that argument to be used with the first window. I can give you code if you like but i dont feel like its necessary right now, im having more of an "access" problem than technical or syntaxic.
does anyone know how i could do this ?
And in my case, would it be better if i used QGraphicsView instead of creating a second Ui file ?
thank you in advance
-
Hello, i'm working on an application and i need to create a second window. So i created a second Ui File, with its cpp class and header. the thing is, i want something in this window to call a function that belongs to the first window, but i havent managed to do this. it looks likes its really difficult to manage multiple ui files. To be more precise, the second window the second window makes a signal with an argument, and i need that argument to be used with the first window. I can give you code if you like but i dont feel like its necessary right now, im having more of an "access" problem than technical or syntaxic.
does anyone know how i could do this ?
And in my case, would it be better if i used QGraphicsView instead of creating a second Ui file ?
thank you in advance
@aftalib said in Mananing multiples Uis or using QGraphicsview ?:
call a function that belongs to the first window, but i havent managed to do this. it looks likes its really difficult to manage multiple ui files.
It is not difficult. You should use signals and slots for that. One window emit a signal another one provides a slot connected to this signal:
MyWindow1 w1; MyWindow2 w2; connect(&w1, &MyWindow1::someSignal, &w2, &MyWindow2::someSlot);That's all.
-
here's what i'm trying to do :
AntArrayDialog w1; connect(ui->treeView,&TreeView::currentItemChanged,&w1,&AntArrayDialog::setFileName);so let met explain : AntArrayDialog is my first Window. i am declaring it in order the method that i want to use here, which is setFileName
in this current window, we have a TreeView, and i also have a treeview class where i reimplemented the eventFilter() method in order to get the signal that you see in the connect (&TreeView::currentItemChanged)
but this code doesnt work. i know that what you wrote is correct but i dont know how to use it in my case
-
@aftalib does your ui treeview is promoted widget?
in this current window, we have a TreeView, and i also have a treeview class where i reimplemented the eventFilter() method in order to get the signal that you see in the connect (&TreeView::currentItemChanged) -
@aftalib does your ui treeview is promoted widget?
in this current window, we have a TreeView, and i also have a treeview class where i reimplemented the eventFilter() method in order to get the signal that you see in the connect (&TreeView::currentItemChanged) -
@aftalib said in Mananing multiples Uis or using QGraphicsview ?:
how can i do this in my case ?
By reading: https://doc.qt.io/qt-5/designer-using-custom-widgets.html
-
@aftalib said in Mananing multiples Uis or using QGraphicsview ?:
it says that i have an "undefined reference" in my ui_ file
read again and think over on how we should help you with this information.
-
@aftalib said in Mananing multiples Uis or using QGraphicsview ?:
what i should do according to this is promote my TreeView that is in my Ui with my treeView class right ?
I don't understand what you're trying to tell me.
The documentation clearly shows you how to promote a QTreeView to a custom TreeView. That your custom TreeView must derive from QTreeView then should be out of question then.
-
i'm sorry, i really dont understand the concept behind this. What i have is :
a Ui File, which i have put a normal TreeView inside of it
a treeview.h and treeview.cpp file where i have redefined the eventFilter() method in order to get the signal i want.
what is the custom TreeView youre talking about ?
-
@aftalib said in Mananing multiples Uis or using QGraphicsview ?:
what is the custom TreeView youre talking about ?
a custom TreeView is a class derived from QTreeView.
-
i'm sorry, i really dont understand the concept behind this. What i have is :
a Ui File, which i have put a normal TreeView inside of it
a treeview.h and treeview.cpp file where i have redefined the eventFilter() method in order to get the signal i want.
what is the custom TreeView youre talking about ?
@aftalib said in Mananing multiples Uis or using QGraphicsview ?:
a treeview.h and treeview.cpp file where i have redefined the eventFilter() method in order to get the signal i want.
What does this mean?
QObject::eventFilter isn't usually involved in application code related to signals and slots.