Qt新的主窗口在从另一个主窗口创建时崩溃了

时间:2012-06-06 17:39:21

标签: qt user-interface mainwindow

程序在图片中崩溃ui->setupUi(this);如果我发表评论,它大部分时间都会完美无缺。操作系统:Windows 7 64位QT 4.8,使用Qt Creator构建。 我不知道为什么。也许像mainwindow一样的命名空间。 错误日志:

  

Starte C:\ psycho \ psycho-build-desktop-Qt_4_8_1_for_Desktop _- MinGW _Qt_SDK__Debug \ debug \ psycho.exe ... Das Programmistabgestürzt。   C:\ psycho \ psycho-build-desktop-Qt_4_8_1_for_Desktop _- MinGW _Qt_SDK__Debug \ debug \ psycho.exe beendet,Rückgabewert-1073741819

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    connect(ui->pushButtonDefault, SIGNAL(clicked()), this, SLOT(setDefault()));
    connect(ui->pushButtonStart, SIGNAL(clicked()), this, SLOT(startGame()));

}

void MainWindow::setDefault()
{
    ui->lineEditTime->setText("1");
    ui->lineEditNumber->setText("0");
}

void MainWindow::startGame()
{
    gameWindow = new pictures();
    gameWindow->show();
}

MainWindow::~MainWindow()
{
    delete ui;
}


#include "pictures.h"
#include "ui_pictures.h"

pictures::pictures(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::pictures), times()
{
    counter = 1;
    stop = 0;

    ui->setupUi(this);
    //this->loadPics();
}

pictures::~pictures()
{
    delete ui;
}

void pictures::loadPics()
{
    std::cout << (QDir::current().absolutePath()  + QDir::separator () + QString::number(counter) + QDir::separator()+"1.jpg").toStdString() << std::endl;
    QImage imageOne((QDir::current().absolutePath()  + QDir::separator () + QString::number(counter) + QDir::separator()+"1.jpg"));
    //QImage imageTwo(QString("./pics/")+counter+"/2.png");
    //QImage imageThree(QString("./pics/")+counter+"/3.jpg");
    //QImage imageFour(QString("./pics/")+counter+"/2.png");


    QGraphicsPixmapItem item1( QPixmap::fromImage(imageOne));
    //QGraphicsPixmapItem item2( QPixmap::fromImage(imageTwo));
    //QGraphicsPixmapItem item3( QPixmap::fromImage(imageThree));
    //QGraphicsPixmapItem item4( QPixmap::fromImage(imageThree));
    QGraphicsScene* scene = new QGraphicsScene;
    scene->addItem(&item1);
    ui->graphicsView->setScene(scene);
    ui->graphicsView->show();

}

0 个答案:

没有答案