
Originally Posted by
wysota
So they are not from the same scene. Basically what you want is achievable but you shouldn't do it. I think your overall design is flawed.
I am going to try to be as detailed as possible about what I am trying to do and I will also include screenshots and code snippets. Below is the screenshot of the software I am trying to develop. I have also made comments on the screenshot.sceenshot1.jpg Now my aim is to have the software load all four pages in the scene at start-up and then I can just navigate from one page to the other as I please. Below is the code snippet for loading pages in the scene.
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setWindowTitle("Elixir");
createActions();
creatTextToolBar();
scene = new Scene(); // scene object
page1 = new Page(scene->sceneRect());
page2 = new Page(scene->sceneRect());
page3 = new Page(scene->sceneRect());
page4 = new Page(scene->sceneRect());
page1->hide();
page2->hide();
page3->hide();
page4->hide();
scene->addItem(page1);
scene->addItem(page2);
scene->addItem(page3);
scene->addItem(page4);
//[1]
ui->WorkArea_view->setScene(scene); //Linking the scence to the view
ui
->WorkArea_view
->setRenderHint
(QPainter::Antialiasing);
//[2] This is the background that holds backgrounds for the outer cover
ui->backgroundsDW->setWindowTitle("Backgrounds");
ui->backgroundsDW->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); //dock widget can only be docked on the left or right side of the screen.
ui->backgroundsDW->hide();
//[3] This is the dockwidget that holds the background types
ui->backgroundsTypeDW->setWindowTitle("Background Type");
ui->backgroundsTypeDW->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
ui->backgroundsTypeDW->hide();
//[4] This is the dockwidget that holds difference presentations of the imported picture.
ui->photoDW->setWindowTitle("Photo");
ui->photoDW->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
ui->photoDW->hide();
//[5] This is the dockwidget that holds frames.
ui->framesDW->setWindowTitle("Frames");
ui->framesDW->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
ui->framesDW->hide();
ui->backgroundsView->setModel(BackgroundsListModel::instance());
ui->framesView->setModel(FramesModel::instance());
//This line connects the double clicking event to painting the background image.
connect(ui
->backgroundsView,
SIGNAL(doubleClicked
(QModelIndex)),
this,
SLOT(setBackgroundOnScene
(QModelIndex)));
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setWindowTitle("Elixir");
createActions();
creatTextToolBar();
scene = new Scene(); // scene object
page1 = new Page(scene->sceneRect());
page2 = new Page(scene->sceneRect());
page3 = new Page(scene->sceneRect());
page4 = new Page(scene->sceneRect());
page1->hide();
page2->hide();
page3->hide();
page4->hide();
scene->addItem(page1);
scene->addItem(page2);
scene->addItem(page3);
scene->addItem(page4);
//[1]
ui->WorkArea_view->setScene(scene); //Linking the scence to the view
ui->WorkArea_view->setRenderHint(QPainter::Antialiasing);
//[2] This is the background that holds backgrounds for the outer cover
ui->backgroundsDW->setWindowTitle("Backgrounds");
ui->backgroundsDW->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); //dock widget can only be docked on the left or right side of the screen.
ui->backgroundsDW->hide();
//[3] This is the dockwidget that holds the background types
ui->backgroundsTypeDW->setWindowTitle("Background Type");
ui->backgroundsTypeDW->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
ui->backgroundsTypeDW->hide();
//[4] This is the dockwidget that holds difference presentations of the imported picture.
ui->photoDW->setWindowTitle("Photo");
ui->photoDW->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
ui->photoDW->hide();
//[5] This is the dockwidget that holds frames.
ui->framesDW->setWindowTitle("Frames");
ui->framesDW->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
ui->framesDW->hide();
ui->backgroundsView->setModel(BackgroundsListModel::instance());
ui->framesView->setModel(FramesModel::instance());
//This line connects the double clicking event to painting the background image.
connect(ui->backgroundsView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setBackgroundOnScene(QModelIndex)));
}
To copy to clipboard, switch view to plain text mode
@wysota, I hope this is detailed enough, and please advise where the design is flawed.
Bookmarks