Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8020345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:40:13+00:00 2026-06-04T21:40:13+00:00

I am working on a program where I create several stacked windows to work

  • 0

I am working on a program where I create several stacked windows to work in with different functions. These windows are made in their own separated classes. One of the stacked windows holds several docks and I want to let them be toggle-able from the windows menu to show or hide them. I can do this if they are part of the mainwindow class but then the file is huge. My problem is that I can not seem to be able to get the layout to even show up when I make the editor class inherit the main window because the main window already has a layout. And even then the compiler was still throwing an error for the line that adds the action to the menu. Does anybody have any suggestions for how I can keep these in separate classes but still be able to use the private members of the mainwindow class. Thanks for the help in advanced!

Part of main window where the editor page is called

MainWindow::MainWindow(QWidget *parent)
{
createActions();
createMenu();
createStatusBar();
createDocks();

createMainWidget();

readSettings();

setWindowTitle("Black Ops Bsuiness Group's ERP System - Version 0.0.0.1");
}

void MainWindow::createMainWidget()
{
contentsIconWidget = new QListWidget();
contentsIconWidget->setViewMode(QListView::IconMode);
contentsIconWidget->setIconSize(QSize(70,70));
contentsIconWidget->setMovement(QListView::Static);
contentsIconWidget->setMaximumWidth(75);
contentsIconWidget->setMinimumWidth(75);
contentsIconWidget->setSpacing(10);
contentsIconWidget->setStyleSheet("QListWidget {background-color:#333;    color:#0099FF;}");

mainContentPages = new QStackedWidget();
mainContentPages->addWidget(new HomePage);
mainContentPages->addWidget(new AnalyticsPage);
mainContentPages->addWidget(new EditorPage);
mainContentPages->setStyleSheet("QStackedWidget {border:1px solid #888;}");
setCentralWidget(mainContentPages);

createIcons();
contentsIconWidget->setCurrentRow(0);

QHBoxLayout *hMainLayout = new QHBoxLayout();
hMainLayout->addWidget(contentsIconWidget,0);
hMainLayout->addWidget(mainContentPages,0);
hMainLayout->setSpacing(0);
hMainLayout->setMargin(0);

QFrame *mFrame = new QFrame(this);
mFrame->setLayout(hMainLayout);
setCentralWidget(mFrame);
}

Part of views source page where the different view states layouts are stored

EditorPage::EditorPage(QWidget *parent) : QWidget(parent)
{
mdiArea = new QMdiArea;
mdiToolBox = new QToolBox;

QDockWidget *dock = new QDockWidget(tr("SQL Manager"));
//MainWindow::windowMenu->addAction(dock->toggleViewAction());
//MainWindow::windowMenu->addAction(dock->toggleViewAction());

QDockWidget *dock1 = new QDockWidget(tr("SQL Manager"));

QSplitter *splitter = new QSplitter();
splitter->setOrientation(Qt::Vertical);
splitter->addWidget(mdiArea);
splitter->addWidget(dock);

QSplitter *splitter1 = new QSplitter();
splitter1->setOrientation(Qt::Horizontal);
splitter1->addWidget(dock1);
splitter1->addWidget(splitter);

QHBoxLayout *mainLayout = new QHBoxLayout();
mainLayout->addWidget(splitter1);
mainLayout->setSpacing(0);
mainLayout->setMargin(0);
setLayout(mainLayout);

}

Part of header file for view classes

class EditorPage : public QWidget
{
public:
EditorPage(QWidget *parent = 0);

private:
QMdiArea *mdiArea;
QToolBox *mdiToolBox;
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:40:14+00:00Added an answer on June 4, 2026 at 9:40 pm

    The Qt way is to use signals and slots for this.

    Your editor window would get a toggleDock() slot (possibly taking an int or an enum value), and the main window would invoke that slot via signals (either a custom signal, something triggered by a QAction, or from a button widget).

    With this, there is no static dependency between your classes.

    (Note that storing the pointers to your dock widgets as members (possibly in an array) will likely make this easier to code.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a simple winsock program working, so I create my socket
I am working on a program and part of it requires me to create
Having successfully gotten a sample program working, I'm now starting to do Real Work
I'm working a program which is parsing some files and than process these files.
I am working on a program that needs to create a multiple temporary folders
I'm working on a program that creates thumbnails of JPEG images on the fly.
I'm currently working on a C# program that creates a List, of object Task,
is there any small working program for recieving from and sending data to client
I have a working program in C++ that generates data for a Mandelbrot Set.
I have a working C program where the length of an array of strings

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.