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. QWidget::windowRole() use as storage for small textual data
Qt 6.11 is out! See what's new in the release blog

QWidget::windowRole() use as storage for small textual data

Scheduled Pinned Locked Moved Solved General and Desktop
33 Posts 4 Posters 5.5k 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

    @Please_Help_me_D
    Yeah as the dumptree clearly shows its the top as we expect
    ads::CDockWidget::2D Window
    QBoxLayout::
    QAction::
    QScrollArea::dockWidgetScrollArea
    QWidget::qt_scrollarea_viewport
    QVTKOpenGLStereoWidget::
    QVBoxLayout::
    ....

    But the test with qApp->focusWidget(); showd now is the Dock so
    looking at this code.

    f (now != nullptr){
    ads::CDockWidget* dockWidget = nullptr;
    QObjectList objList = now->children();

    Do you only check its children ?
    and in that case, the line
    dockWidget = qobject_castads::CDockWidget*(objList.at(i));

    will always return null as you skip the now ? and only cast children ?

    Please_Help_me_DP Offline
    Please_Help_me_DP Offline
    Please_Help_me_D
    wrote on last edited by Please_Help_me_D
    #24

    @mrjj let me clarify one moment.
    Earlier wrote an unclear post about what widget which dumptree has.
    Also there are two possible ways how ads::CDockWidget is attached to the application:

    1. CDockWidget is tabbed
    2. CDockWidget is float (we can pick and drag it as it is like a new window)

    So we have different dumptrees for QWidget* now object on onFocusChanged(QWidget* old, QWidget* now)

    Here is dumptree for tabbed CDOckWidget:

    ads::CDockWidgetTab:: 
        QBoxLayout:: 
        ads::CElidingLabel::dockWidgetTabLabel 
        QPushButton::tabCloseButton 
    

    And here is for float CDockWidget:

    QScrollArea::dockWidgetScrollArea 
        QWidget::qt_scrollarea_viewport 
            QVTKOpenGLStereoWidget:: 
                QVBoxLayout:: 
                QWindowContainer:: 
        QWidget::qt_scrollarea_hcontainer 
            QScrollBar:: 
            QBoxLayout:: 
        QWidget::qt_scrollarea_vcontainer 
            QScrollBar:: 
            QBoxLayout:: 
    

    So we have a deal with two types of top level widgets :)
    But I would like to set the property only to a single type widget and if onFocusChanged() look for that object in now widget

    mrjjM 1 Reply Last reply
    0
    • Please_Help_me_DP Please_Help_me_D

      @mrjj let me clarify one moment.
      Earlier wrote an unclear post about what widget which dumptree has.
      Also there are two possible ways how ads::CDockWidget is attached to the application:

      1. CDockWidget is tabbed
      2. CDockWidget is float (we can pick and drag it as it is like a new window)

      So we have different dumptrees for QWidget* now object on onFocusChanged(QWidget* old, QWidget* now)

      Here is dumptree for tabbed CDOckWidget:

      ads::CDockWidgetTab:: 
          QBoxLayout:: 
          ads::CElidingLabel::dockWidgetTabLabel 
          QPushButton::tabCloseButton 
      

      And here is for float CDockWidget:

      QScrollArea::dockWidgetScrollArea 
          QWidget::qt_scrollarea_viewport 
              QVTKOpenGLStereoWidget:: 
                  QVBoxLayout:: 
                  QWindowContainer:: 
          QWidget::qt_scrollarea_hcontainer 
              QScrollBar:: 
              QBoxLayout:: 
          QWidget::qt_scrollarea_vcontainer 
              QScrollBar:: 
              QBoxLayout:: 
      

      So we have a deal with two types of top level widgets :)
      But I would like to set the property only to a single type widget and if onFocusChanged() look for that object in now widget

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

      @Please_Help_me_D
      aha. I missed the being tabbed part.
      So when tabbed, the Dock becomes a CDockWidgetTab and the Dock is not around any more?

      Please_Help_me_DP 1 Reply Last reply
      0
      • mrjjM mrjj

        @Please_Help_me_D
        aha. I missed the being tabbed part.
        So when tabbed, the Dock becomes a CDockWidgetTab and the Dock is not around any more?

        Please_Help_me_DP Offline
        Please_Help_me_DP Offline
        Please_Help_me_D
        wrote on last edited by
        #26

        @mrjj when tabbed the focused widget is CDockWidgetTab (because I do this dumptree on the now widget when certain widget is focused). And I don't know exactly where CDockWidget disappears :)

        mrjjM 1 Reply Last reply
        0
        • Please_Help_me_DP Please_Help_me_D

          @mrjj when tabbed the focused widget is CDockWidgetTab (because I do this dumptree on the now widget when certain widget is focused). And I don't know exactly where CDockWidget disappears :)

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

          @Please_Help_me_D
          Is CDockWidget just a normal QDockWidget ?

          alt text

          Please_Help_me_DP 1 Reply Last reply
          0
          • mrjjM mrjj

            @Please_Help_me_D
            Is CDockWidget just a normal QDockWidget ?

            alt text

            Please_Help_me_DP Offline
            Please_Help_me_DP Offline
            Please_Help_me_D
            wrote on last edited by
            #28

            @mrjj here it is
            60fdf08f-d549-41cb-9f34-b63f0c12d046-image.png

            with the code:

            void MainWindow::onFocusChanged(QWidget* old, QWidget* now){
                if (now != nullptr){
                    now->dumpObjectTree();
                }
            }
            

            I started interactively change focused window and the qDebug output shows me that the toplevel widget of dumpObjectTree depends upon where I click: if I click on the QTreeWidget the this widget is on the rop, if on the label then CDockWidgetTab is on the top...

            mrjjM 1 Reply Last reply
            0
            • Please_Help_me_DP Please_Help_me_D

              @mrjj here it is
              60fdf08f-d549-41cb-9f34-b63f0c12d046-image.png

              with the code:

              void MainWindow::onFocusChanged(QWidget* old, QWidget* now){
                  if (now != nullptr){
                      now->dumpObjectTree();
                  }
              }
              

              I started interactively change focused window and the qDebug output shows me that the toplevel widget of dumpObjectTree depends upon where I click: if I click on the QTreeWidget the this widget is on the rop, if on the label then CDockWidgetTab is on the top...

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

              @Please_Help_me_D
              Hi
              I think its a custom setup as it dont look the same for Qt exmaples
              alt text

              Is CDockWidget your own class ?

              Please_Help_me_DP 1 Reply Last reply
              0
              • mrjjM mrjj

                @Please_Help_me_D
                Hi
                I think its a custom setup as it dont look the same for Qt exmaples
                alt text

                Is CDockWidget your own class ?

                Please_Help_me_DP Offline
                Please_Help_me_DP Offline
                Please_Help_me_D
                wrote on last edited by
                #30

                @mrjj it is a standalone library link text

                mrjjM 1 Reply Last reply
                0
                • Please_Help_me_DP Please_Help_me_D

                  @mrjj it is a standalone library link text

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

                  @Please_Help_me_D
                  ah. its looks awesome.
                  Ok so that makes sense. So it will actually hide the dock and the tab
                  is the parent.
                  That means setting your value on teh Dock will not work as it not there when tabbed.

                  You could instead add a plain QWidget + layout + qvtkOpenGLStereoWidget/ what you normal put in the dock
                  so that we always have this QWidget as top and you can add the dynamic property there.
                  This ofcause adds extra widget to all docks so if you have huge tons of them, it might be wasteful.

                  Please_Help_me_DP 1 Reply Last reply
                  1
                  • mrjjM mrjj

                    @Please_Help_me_D
                    ah. its looks awesome.
                    Ok so that makes sense. So it will actually hide the dock and the tab
                    is the parent.
                    That means setting your value on teh Dock will not work as it not there when tabbed.

                    You could instead add a plain QWidget + layout + qvtkOpenGLStereoWidget/ what you normal put in the dock
                    so that we always have this QWidget as top and you can add the dynamic property there.
                    This ofcause adds extra widget to all docks so if you have huge tons of them, it might be wasteful.

                    Please_Help_me_DP Offline
                    Please_Help_me_DP Offline
                    Please_Help_me_D
                    wrote on last edited by
                    #32

                    @mrjj said in QWidget::windowRole() use as storage for small textual data:

                    You could instead add a plain QWidget + layout + qvtkOpenGLStereoWidget/ what you normal put in the dock
                    so that we always have this QWidget as top and you can add the dynamic property there.
                    This ofcause adds extra widget to all docks so if you have huge tons of them, it might be wasteful.

                    Could you please explain this a little bit more? Can't understand the idea.
                    Or we could postpone it till tomorrow it is late night :)

                    mrjjM 1 Reply Last reply
                    0
                    • Please_Help_me_DP Please_Help_me_D

                      @mrjj said in QWidget::windowRole() use as storage for small textual data:

                      You could instead add a plain QWidget + layout + qvtkOpenGLStereoWidget/ what you normal put in the dock
                      so that we always have this QWidget as top and you can add the dynamic property there.
                      This ofcause adds extra widget to all docks so if you have huge tons of them, it might be wasteful.

                      Could you please explain this a little bit more? Can't understand the idea.
                      Or we could postpone it till tomorrow it is late night :)

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

                      @Please_Help_me_D
                      Yes let do it tomorrow as im also tired :)
                      Its nothing complicated just extra widget with a layout that holds your normal content.
                      Im assuminng that even CDock will go away, your actual content still exists so if we add a new QWidget that
                      is always included we could add the property there.

                      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