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. Combining widgets
Qt 6.11 is out! See what's new in the release blog

Combining widgets

Scheduled Pinned Locked Moved Unsolved General and Desktop
34 Posts 4 Posters 11.9k Views 2 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.
  • mrjjM mrjj

    @TETTRA
    There is no premade , just to use solution. ( that i have seen)
    The code @VRonin provide is a good starting point.

    You should read about QDockWidget and how it works. Then
    try to make it.

    http://doc.qt.io/qt-5/qdockwidget.html
    this one also cover it.
    http://www.informit.com/articles/article.aspx?p=1405543&seqNum=5

    If you are brand new to Qt, it's not a good start project as such as it will take
    some fiddling to feel like photoshop.

    T Offline
    T Offline
    TETTRA
    wrote on last edited by TETTRA
    #17

    @mrjj You right. How can I designate the correct answer? And yet, how to do it, if I have everything in different files?(From projectWindow, I want to make a QDockWidget. Is it possible?) ! sorry for this bad picture

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #18
      • I want to make a QDockWidget. Is it possible?

      You mean you want to include the widgets from other files?

      Ys, just include the .h from the other widgets into the Dock one and
      then you can create those from code. ( and insert into Dock)

      T 1 Reply Last reply
      5
      • mrjjM mrjj
        • I want to make a QDockWidget. Is it possible?

        You mean you want to include the widgets from other files?

        Ys, just include the .h from the other widgets into the Dock one and
        then you can create those from code. ( and insert into Dock)

        T Offline
        T Offline
        TETTRA
        wrote on last edited by
        #19

        @mrjj Sorry, but I'm new, could you give me an example?

        mrjjM 1 Reply Last reply
        0
        • T TETTRA

          @mrjj Sorry, but I'm new, could you give me an example?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #20

          @TETTRA
          Example on ?

          T 1 Reply Last reply
          1
          • mrjjM mrjj

            @TETTRA
            Example on ?

            T Offline
            T Offline
            TETTRA
            wrote on last edited by
            #21

            @mrjj Yes

            mrjjM 1 Reply Last reply
            0
            • T TETTRA

              @mrjj Yes

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #22

              @TETTRA
              sorry ?
              you just include the .h file and then u can use the class

              //somefile.cpp
              #include "mywidget.h"
              then you can do
              mywidget * w= new mywidget();

              T 1 Reply Last reply
              3
              • mrjjM mrjj

                @TETTRA
                sorry ?
                you just include the .h file and then u can use the class

                //somefile.cpp
                #include "mywidget.h"
                then you can do
                mywidget * w= new mywidget();

                T Offline
                T Offline
                TETTRA
                wrote on last edited by TETTRA
                #23

                @mrjj It doesn't work out for me.

                DockWidget:

                #include "dockwodgets.h"
                #include "stylehelper.h"
                
                dockWodgets::dockWodgets()
                {
                    layer = new QDockWidget();
                }
                
                

                Connect:

                //docks
                             docks = new dockWodgets();
                
                mrjjM 1 Reply Last reply
                0
                • T TETTRA

                  @mrjj It doesn't work out for me.

                  DockWidget:

                  #include "dockwodgets.h"
                  #include "stylehelper.h"
                  
                  dockWodgets::dockWodgets()
                  {
                      layer = new QDockWidget();
                  }
                  
                  

                  Connect:

                  //docks
                               docks = new dockWodgets();
                  
                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #24

                  @TETTRA
                  you must give more details.
                  what is error ?
                  what does not work ?
                  I cant tell anything from that code :)
                  seems fine.

                  T 1 Reply Last reply
                  1
                  • mrjjM mrjj

                    @TETTRA
                    you must give more details.
                    what is error ?
                    what does not work ?
                    I cant tell anything from that code :)
                    seems fine.

                    T Offline
                    T Offline
                    TETTRA
                    wrote on last edited by
                    #25

                    @mrjj
                    DockWidget

                    #include "dockwodgets.h"
                    #include "stylehelper.h"
                    
                    dockWodgets::dockWodgets()
                    {
                        layer = new QDockWidget();
                    }
                    

                    MainWindow

                      //docks
                                 docks = new dockWodgets();
                    

                    That's all I did. My program is running, but the "docks" isn,t shown.

                    mrjjM 1 Reply Last reply
                    0
                    • T TETTRA

                      @mrjj
                      DockWidget

                      #include "dockwodgets.h"
                      #include "stylehelper.h"
                      
                      dockWodgets::dockWodgets()
                      {
                          layer = new QDockWidget();
                      }
                      

                      MainWindow

                        //docks
                                   docks = new dockWodgets();
                      

                      That's all I did. My program is running, but the "docks" isn,t shown.

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #26

                      @TETTRA
                      make sure to show() on it.
                      layer = new QDockWidget();
                      layer->show();

                      T 1 Reply Last reply
                      0
                      • mrjjM mrjj

                        @TETTRA
                        make sure to show() on it.
                        layer = new QDockWidget();
                        layer->show();

                        T Offline
                        T Offline
                        TETTRA
                        wrote on last edited by TETTRA
                        #27

                        @mrjj This widget simply opens. I need him open already and attached to the main window.

                        mrjjM 1 Reply Last reply
                        0
                        • T TETTRA

                          @mrjj This widget simply opens. I need him open already and attached to the main window.

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #28

                          @TETTRA
                          You also need to add it to the mainwindow with
                          http://doc.qt.io/qt-5/qmainwindow.html#addDockWidget

                          T 1 Reply Last reply
                          0
                          • mrjjM mrjj

                            @TETTRA
                            You also need to add it to the mainwindow with
                            http://doc.qt.io/qt-5/qmainwindow.html#addDockWidget

                            T Offline
                            T Offline
                            TETTRA
                            wrote on last edited by TETTRA
                            #29

                            @mrjj like this?

                            void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockWidget, Qt::Orientation orientation){
                                       dockWidgets *docks = new dockWidgets();
                                        docks->show();
                            }
                            
                            mrjjM 1 Reply Last reply
                            0
                            • T TETTRA

                              @mrjj like this?

                              void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockWidget, Qt::Orientation orientation){
                                         dockWidgets *docks = new dockWidgets();
                                          docks->show();
                              }
                              
                              mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by
                              #30

                              @TETTRA
                              no ?
                              The function already exists.
                              so you just need to call it. not define a new function.

                              QDockWidget * mine== new QDockWidget;
                              addDockWidget(Qt::LeftDockWidgetArea, mine); // this is build in function.

                              Maybe you should try the dock sample first
                              http://doc.qt.io/qt-5/qtwidgets-mainwindows-dockwidgets-example.html

                              T 1 Reply Last reply
                              1
                              • mrjjM mrjj

                                @TETTRA
                                no ?
                                The function already exists.
                                so you just need to call it. not define a new function.

                                QDockWidget * mine== new QDockWidget;
                                addDockWidget(Qt::LeftDockWidgetArea, mine); // this is build in function.

                                Maybe you should try the dock sample first
                                http://doc.qt.io/qt-5/qtwidgets-mainwindows-dockwidgets-example.html

                                T Offline
                                T Offline
                                TETTRA
                                wrote on last edited by
                                #31

                                @mrjj I wrote,

                                dockWidgets *dock = new dockWidgets;
                                             addDockWidget(Qt::LeftDockWidgetArea, dock);
                                

                                but I didn't get anything done

                                mrjjM 1 Reply Last reply
                                0
                                • T TETTRA

                                  @mrjj I wrote,

                                  dockWidgets *dock = new dockWidgets;
                                               addDockWidget(Qt::LeftDockWidgetArea, dock);
                                  

                                  but I didn't get anything done

                                  mrjjM Offline
                                  mrjjM Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #32

                                  @TETTRA

                                  Cant explain.
                                  Try the sample first to get friends with Docks.
                                  also
                                  is dockWidgets
                                  a QDockWidget?
                                  the (s) is confusing.

                                  T 1 Reply Last reply
                                  0
                                  • mrjjM mrjj

                                    @TETTRA

                                    Cant explain.
                                    Try the sample first to get friends with Docks.
                                    also
                                    is dockWidgets
                                    a QDockWidget?
                                    the (s) is confusing.

                                    T Offline
                                    T Offline
                                    TETTRA
                                    wrote on last edited by
                                    #33

                                    @mrjj said in Combining widgets:

                                    Try the sample first to get friends with Docks.
                                    also
                                    is dockWidgets
                                    a QDockWidget?
                                    the (s) is confusing.

                                    So I have it in another (. Cpp) file!

                                    mrjjM 1 Reply Last reply
                                    0
                                    • T TETTRA

                                      @mrjj said in Combining widgets:

                                      Try the sample first to get friends with Docks.
                                      also
                                      is dockWidgets
                                      a QDockWidget?
                                      the (s) is confusing.

                                      So I have it in another (. Cpp) file!

                                      mrjjM Offline
                                      mrjjM Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #34

                                      @TETTRA
                                      well as long as the class inherited QDockWidget it should be fine.

                                      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