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. Why toolbar in docked window is not visible properly
Qt 6.11 is out! See what's new in the release blog

Why toolbar in docked window is not visible properly

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 543 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.
  • M Offline
    M Offline
    manugoel
    wrote on last edited by manugoel
    #1

    I am trying to create a docked widget. In the docked widget, when I try to create a toolbar, tool bar is not visible properly -

    0664bd02-4128-405a-9b8e-b73c24e2dab5-image.png

    As you can see in the highlighted portion, the tool-bar is overlapping the chart and is also very small. What could be reason?

    Here is how I am creating the docked window and the toolbar -

    // Code to create docked window from Mainwindow
    QDockWidget *dock = new QDockWidget(tr("Histogram"), this);
    dock->setAllowedAreas(Qt::BottomDockWidgetArea);
    histogramWin = new histogram(dock);
    addDockWidget(Qt::BottomDockWidgetArea, dock);
    dock->setMinimumSize(this->size().width(), this->size().height()/2);

        histogramWin->showHistogram(); //populates histogram widget data
    

    // declaration of class histogram
    class histogram : public QChartView

    // constructor if histogram
    histogram::histogram(QDockWidget* dockWidget)
    : chartView (new QChartView(dockWidget))
    {
    dockWidgetPtr = dockWidget;
    createToolbar();
    chart = chartView->chart();
    dockWidget->setWidget(chartView);
    series = new QStackedBarSeries();
    }

    //this creates toolbar
    void histogram::createToolbar()
    {
    QToolBar *toolBar = new QToolBar(chartView);
    QLabel *startTimelabel = new QLabel("Histo Start Time");
    toolBar->addWidget(startTimelabel);
    toolBar->show();
    toolBar->setAllowedAreas(Qt::TopToolBarArea);

    expandBarAct = new QAction( tr("Expand"), this);
    expandBarAct->setStatusTip(tr("Expand the selected bar"));
    expandBarAct->setToolTip(tr("Expand the selected bar"));
    connect(expandBarAct, &QAction::triggered, this, &histogram::expandBar);
    toolBar->addAction(expandBarAct);
    

    }

    Any suggestions to fix the toolbar visibility issue?

    Thanks.

    M 1 Reply Last reply
    0
    • M manugoel

      I am trying to create a docked widget. In the docked widget, when I try to create a toolbar, tool bar is not visible properly -

      0664bd02-4128-405a-9b8e-b73c24e2dab5-image.png

      As you can see in the highlighted portion, the tool-bar is overlapping the chart and is also very small. What could be reason?

      Here is how I am creating the docked window and the toolbar -

      // Code to create docked window from Mainwindow
      QDockWidget *dock = new QDockWidget(tr("Histogram"), this);
      dock->setAllowedAreas(Qt::BottomDockWidgetArea);
      histogramWin = new histogram(dock);
      addDockWidget(Qt::BottomDockWidgetArea, dock);
      dock->setMinimumSize(this->size().width(), this->size().height()/2);

          histogramWin->showHistogram(); //populates histogram widget data
      

      // declaration of class histogram
      class histogram : public QChartView

      // constructor if histogram
      histogram::histogram(QDockWidget* dockWidget)
      : chartView (new QChartView(dockWidget))
      {
      dockWidgetPtr = dockWidget;
      createToolbar();
      chart = chartView->chart();
      dockWidget->setWidget(chartView);
      series = new QStackedBarSeries();
      }

      //this creates toolbar
      void histogram::createToolbar()
      {
      QToolBar *toolBar = new QToolBar(chartView);
      QLabel *startTimelabel = new QLabel("Histo Start Time");
      toolBar->addWidget(startTimelabel);
      toolBar->show();
      toolBar->setAllowedAreas(Qt::TopToolBarArea);

      expandBarAct = new QAction( tr("Expand"), this);
      expandBarAct->setStatusTip(tr("Expand the selected bar"));
      expandBarAct->setToolTip(tr("Expand the selected bar"));
      connect(expandBarAct, &QAction::triggered, this, &histogram::expandBar);
      toolBar->addAction(expandBarAct);
      

      }

      Any suggestions to fix the toolbar visibility issue?

      Thanks.

      M Offline
      M Offline
      manugoel
      wrote on last edited by
      #2

      I was able to solve the problem, I created a QBoxLayout and added toolbar and main widget in that.

      Thanks.

      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