Название: Ошибка с кодом -1073741819
Отправлено: demaker от Ноября 08, 2012, 11:02
Добрый день!
Переписал пример с книги,все компилится. Запускаю,вроде работает. когда начинаю производить дальнейшие манипуляции то выкидывает ошибку с кодом -1073741819.
Проблема в этой части кода, но я не могу понять где именно. QList<QMdiSubWindow*>winList = mdiArea->subWindowList(); separatorAct->setVisible(!winList.isEmpty()); for(int i = 0; i<winList.size(); ++i) { MdiChildJournal* child = qobject_cast<MdiChildJournal*>(winList.at(i)->widget());
QString text; if(i<9) { text = tr("&%1 &%2").arg(i+1).arg(child->userFriendlyCurrentFile()); } else { text = tr("&%1 &%2").arg(i+1).arg(child->userFriendlyCurrentFile()); }
QAction*action = windowMenu->addAction(text); action->setCheckable(true); action->setChecked(child==activeMdiChild()); connect(action,SIGNAL(triggered()),windowMapper,SLOT(map())); windowMapper->setMapping(action,winList.at(i));
Что делать?
Название: Re: Ошибка с кодом -1073741819
Отправлено: Пантер от Ноября 08, 2012, 11:54
1. Какие манипуляции? 2. Дебажил? 3. Оформляй тегом code. 4. Давай больше кода.
Название: Re: Ошибка с кодом -1073741819
Отправлено: demaker от Ноября 08, 2012, 12:19
#include "mainwindow.h" #include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this);
mdiArea = new QMdiArea; setCentralWidget(mdiArea); connect(mdiArea,SIGNAL(subWindowActivated(QMdiSubWindow*)),this, SLOT(updateMenus()));
windowMapper = new QSignalMapper(this); connect(windowMapper,SIGNAL(mapped(QWidget*)),this,SLOT(setActiveSubWindow(QWidget*)));
mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
createActions(); createMenus(); createToolBars(); createStatusBar(); updateMenus(); setWindowTitle(tr("MDI")); setGeometry(200,200,400,200);
/*p_lblX = new QLabel(this); p_lblY = new QLabel(this); */ }
MainWindow::~MainWindow() { delete ui; }
void MainWindow::mouseMoveEvent(QMouseEvent *pe) { //p_lblX->setText("X="+QString().setNum(pe->x())); //p_lblY->setText("Y="+QString().setNum(pe->y())); }
void MainWindow::closeEvent(QCloseEvent *pe) { //??????????????????????????? mdiArea->closeAllSubWindows(); //if(activeMdiChild()) //{ // pe->ignore(); //} //else //{ // pe->accept(); //} }
void MainWindow::newFile() { MdiChildJournal* child = createMdiChild(); child->newFile(); child->show(); }
void MainWindow::about() {
}
void MainWindow::updateMenus() {
}
void MainWindow::updateWindowMenu() { windowMenu->clear(); windowMenu->addAction(closeAct); windowMenu->addAction(closeAllAct); windowMenu->addSeparator(); windowMenu->addAction(nextAct);
/*QList<QMdiSubWindow*>winList = mdiArea->subWindowList(); separatorAct->setVisible(!winList.isEmpty()); for(int i = 0; i<winList.size(); ++i) { MdiChildJournal* child = qobject_cast<MdiChildJournal*>(winList.at(i)->widget());
QString text; if(i<9) { text = tr("&%1 &%2").arg(i+1).arg(child->userFriendlyCurrentFile()); } else { text = tr("&%1 &%2").arg(i+1).arg(child->userFriendlyCurrentFile()); }
QAction*action = windowMenu->addAction(text); action->setCheckable(true); action->setChecked(child==activeMdiChild()); connect(action,SIGNAL(triggered()),windowMapper,SLOT(map())); windowMapper->setMapping(action,winList.at(i)); } */ }
MdiChildJournal* MainWindow::createMdiChild() { MdiChildJournal*child = new MdiChildJournal(); mdiArea->addSubWindow(child); return child; }
void MainWindow::createActions() { newAct = new QAction(tr("&New"),this); newAct->setShortcut(tr("Ctrl+N")); newAct->setStatusTip(tr("Create new journal")); connect(newAct,SIGNAL(triggered()),this,SLOT(newFile()));
exitAct = new QAction(tr("&Exit"),this); exitAct->setShortcut(tr("Alt+X")); exitAct->setStatusTip(tr("Exit"));
closeAct = new QAction(tr("&Close"),this); closeAct->setShortcut(tr("Alt+C")); closeAct->setStatusTip(tr("Close Window"));
closeAllAct = new QAction(tr("&Close All"),this); closeAllAct->setShortcut(tr("Alt+A")); closeAllAct->setStatusTip(tr("Close All Window"));
nextAct = new QAction(tr("&Next"),this); nextAct->setShortcut(tr("Shift+N")); nextAct->setStatusTip(tr("Next Window")); }
void MainWindow::createMenus() { fileMenu = menuBar()->addMenu(tr("&File")); fileMenu->addAction(newAct); fileMenu->addSeparator(); fileMenu->addAction(exitAct);
windowMenu = menuBar()->addMenu(tr("&Window")); updateMenus(); connect(windowMenu,SIGNAL(aboutToShow()),this,SLOT(updateWindowMenu())); menuBar()->addSeparator(); }
void MainWindow::createToolBars() {
}
void MainWindow::createStatusBar() {
}
MdiChildJournal*MainWindow::activeMdiChild() {
}
QMdiSubWindow*MainWindow::findMdiChild(const QString &fileName) {
}
void MainWindow::setActiveSubWindow(QWidget *window) {
}
Хочу сделать MDI При нажатии на window в меню вылетает :( с ошибкой -1073741819 Если надо могу преслать код MdiChildJournal
Название: Re: Ошибка с кодом -1073741819
Отправлено: LisandreL от Ноября 08, 2012, 13:39
Обращение к несозданному или удалённому объекту. Локализуйте с помощью дебагера до строчки и выясняйте что там с объектом.
Название: Re: Ошибка с кодом -1073741819
Отправлено: demaker от Ноября 08, 2012, 14:51
Работал в отладчики выдал сообщение
Приложение было остановлено т.к получило сигнал от операционный системы. Сигнал: SIGSGV
Название: Re: Ошибка с кодом -1073741819
Отправлено: Пантер от Ноября 08, 2012, 14:56
А посмотреть стектрейс?
Название: Re: Ошибка с кодом -1073741819
Отправлено: demaker от Ноября 08, 2012, 15:03
:o
Название: Re: Ошибка с кодом -1073741819
Отправлено: demaker от Ноября 09, 2012, 09:28
А где это такое находится ???
|