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. Want to create a DockeWidget on the fly
QtWS25 Last Chance

Want to create a DockeWidget on the fly

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 1.4k Views
  • 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    I have a class like
    class MyQActions : public QObject {

    private:
    QAction* d_action;
    QMainWindow* d_parent;
    MyView* d_myView;

    public:
    check();

    }

    MyQAction::MYQAction {

    d_actiont = act = new IN_CURRENT_POOL QAction(tr("Meny), this);
    connect(act, SIGNAL(triggered()), this, SLOT(myFunc()));

    }

    MyAction:myFunc(){

    I want to create a docke widget here on the fly
    // create a QWidget
    like
    d_myView= new GQMyView(d_parent);

    if (corner == Qt::NoDockWidgetArea) {
    setCentralWidget(d_regionWidget);
    return NULL;
    } else {
    QDockWidget* w = addDockWidget(d_myView, tr(Label1"), true, (Qt::DockWidgetArea corner));
    w->setFloating(true)
    }

    }

    class MyView: public QWidget {

    }

    Can I do this and and When the user closes this QWidget I want to destroy this docked widget How to do it

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      Qt Enthusiast
      wrote on last edited by
      #2

      Basically it should act a dialogue but I should be able to dock it

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        If you put a widget in a QDockWidget then what you are going to close is the dock widget itself not the contained widget. So if you want to destroy both you'll have to put something like a "destroy me" button. Note that this is the kind of behavior that's a bit counter intuitive. Why do you want such a "dialog" for ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          Qt Enthusiast
          wrote on last edited by
          #4

          The requirement is When I click the menu in QT Gui a window should come up as floating The window will be reporting a data . The user will see these reports and make changes in one of the other view of GUI
          Thus the requirement is if the user wants to dock it and keep it to side of other window and work side by side then he should be able and Once the user works done the user should be able to close /destroy the widget .Next time when The user clicks menu and again the new floating window should come up.

          This is because . if create the widget as docked it will remain it GUI . which is not required . This window should be created on the fly

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            You can create it and not show it until needed.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              Qt Enthusiast
              wrote on last edited by
              #6

              Could you please guide me a little bit of how to do that and let me know some sample example

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Basically don't construct it until needed and that's pretty much it. You can also use the toggleViewAction if you want your user to be able to hide/show the dock widget at will.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                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