Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Mananing multiples Uis or using QGraphicsview ?
Forum Updated to NodeBB v4.3 + New Features

Mananing multiples Uis or using QGraphicsview ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 5 Posters 776 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aftalib
    wrote on last edited by aftalib
    #1

    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

    jsulmJ 1 Reply Last reply
    0
    • A aftalib

      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

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • A Offline
        A Offline
        aftalib
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • nageshN Offline
          nageshN Offline
          nagesh
          wrote on last edited by
          #4

          @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)
          
          A 1 Reply Last reply
          0
          • nageshN nagesh

            @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)
            
            A Offline
            A Offline
            aftalib
            wrote on last edited by
            #5

            @nagesh i didnt know about the promoting widget mechanism. how can i do this in my case ?

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @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

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              1
              • A Offline
                A Offline
                aftalib
                wrote on last edited by
                #7

                ive tried this but it really doesnt solve my problem. it says that i have an "undefined reference" in my ui_ file

                1 Reply Last reply
                0
                • Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @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.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    aftalib
                    wrote on last edited by
                    #9

                    what i should do according to this is promote my TreeView that is in my Ui with my treeView class right ?

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @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.

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        aftalib
                        wrote on last edited by
                        #11

                        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 ?

                        jeremy_kJ 1 Reply Last reply
                        0
                        • Christian EhrlicherC Offline
                          Christian EhrlicherC Offline
                          Christian Ehrlicher
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @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.

                          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                          Visit the Qt Academy at https://academy.qt.io/catalog

                          1 Reply Last reply
                          0
                          • A aftalib

                            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 ?

                            jeremy_kJ Online
                            jeremy_kJ Online
                            jeremy_k
                            wrote on last edited by
                            #13

                            @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.

                            Asking a question about code? http://eel.is/iso-c++/testcase/

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved