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 12.0k 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.
  • VRoninV VRonin

    http://doc.qt.io/qt-5/qmdiarea.html ?

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

    @VRonin Do you use AdobePhotoshop? There different windows. When a new project is created, it appears as a separate window and then it is merged with the main window.

    VRoninV 1 Reply Last reply
    0
    • T TETTRA

      @VRonin Do you use AdobePhotoshop? There different windows. When a new project is created, it appears as a separate window and then it is merged with the main window.

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #8

      @TETTRA said in Combining widgets:

      Do you use AdobePhotoshop?

      I'm not that rich.

      I think what you mean can be achieved either reimplemnting drag and drop or using QMainWindow as a central widget of another QMainWindow and spawning QDockWidgets from it

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      T 1 Reply Last reply
      0
      • VRoninV VRonin

        @TETTRA said in Combining widgets:

        Do you use AdobePhotoshop?

        I'm not that rich.

        I think what you mean can be achieved either reimplemnting drag and drop or using QMainWindow as a central widget of another QMainWindow and spawning QDockWidgets from it

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

        @VRonin Excuse me but I didn'i understand a bit. Can you give me some example?

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by VRonin
          #10

          Something like:

          class ExampleWid : QMainWindow{
          Q_OBJECT
          Q_DISABLE_COPY(ExampleWid)
          public:
          explicit ExampleWid(QWidget* parent = Q_NULLPTR)
          :QMainWindow(parent)
          {
          m_centralWid=new QMainWindow(this);
          m_centralWid->setWindowFlags(Qt::Widget);
          setCentralWidget(m_centralWid);
          }
          public slots:
          void spawnWidget(){
          auto tempLabel = new QLabel("exaple");
          auto tempDock = new QDockWidget("example dock");
          tempDock.setWidget(tempLabel);
          m_centralWid->addDockWidget(Qt::NoDockWidgetArea,tempDock);
          }
          private:
          QMainWindow* m_centralWid;
          };
          

          call spawnWidget to create new windows

          Edit

          addDockWidget shold be called from the central widget

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          T 1 Reply Last reply
          6
          • VRoninV VRonin

            Something like:

            class ExampleWid : QMainWindow{
            Q_OBJECT
            Q_DISABLE_COPY(ExampleWid)
            public:
            explicit ExampleWid(QWidget* parent = Q_NULLPTR)
            :QMainWindow(parent)
            {
            m_centralWid=new QMainWindow(this);
            m_centralWid->setWindowFlags(Qt::Widget);
            setCentralWidget(m_centralWid);
            }
            public slots:
            void spawnWidget(){
            auto tempLabel = new QLabel("exaple");
            auto tempDock = new QDockWidget("example dock");
            tempDock.setWidget(tempLabel);
            m_centralWid->addDockWidget(Qt::NoDockWidgetArea,tempDock);
            }
            private:
            QMainWindow* m_centralWid;
            };
            

            call spawnWidget to create new windows

            Edit

            addDockWidget shold be called from the central widget

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

            @VRonin It's not what it takes. Sorry

            mrjjM 1 Reply Last reply
            0
            • T TETTRA

              @VRonin It's not what it takes. Sorry

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

              @TETTRA
              Hi
              You really have to explain a bit better what you want. :)

              I do use photoshop cc 2014 and i have no idea what you mean.

              You mean tear off windows, ( from a tab ) to a floating window and then be able to drag back again to a tab ?

              T 1 Reply Last reply
              1
              • mrjjM mrjj

                @TETTRA
                Hi
                You really have to explain a bit better what you want. :)

                I do use photoshop cc 2014 and i have no idea what you mean.

                You mean tear off windows, ( from a tab ) to a floating window and then be able to drag back again to a tab ?

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

                @mrjj Exactly this!!!!!

                mrjjM 1 Reply Last reply
                0
                • T TETTRA

                  @mrjj Exactly this!!!!!

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

                  @TETTRA
                  Ok. Then @VRonin code is the way to go.
                  Its not directly supported by the Docks. (to dock in center)
                  They will only docks to the sides. ( and only dock in mainwindows)
                  But it is possible to cheat and and use an extra mainwindow and use that for the central docking so
                  one can get that effect. But it takes some tweaking and fiddling to get it to work.

                  T 1 Reply Last reply
                  5
                  • mrjjM mrjj

                    @TETTRA
                    Ok. Then @VRonin code is the way to go.
                    Its not directly supported by the Docks. (to dock in center)
                    They will only docks to the sides. ( and only dock in mainwindows)
                    But it is possible to cheat and and use an extra mainwindow and use that for the central docking so
                    one can get that effect. But it takes some tweaking and fiddling to get it to work.

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

                    Can you tell me how to do this? Give some kind of example, pls

                    mrjjM 1 Reply Last reply
                    1
                    • T TETTRA

                      Can you tell me how to do this? Give some kind of example, pls

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

                      @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 1 Reply Last reply
                      4
                      • 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

                                          • Login

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