Пример #1
2
void MainWindow::funS()
{
    QLabel* l = new QLabel;
    l->setWindowTitle("Fun");
    l->setFixedSize(765, 500);

    QObject::connect( this, SIGNAL( closeSignal() ), l, SLOT( close() ) );

    QRect rect(l->contentsRect());
    QPainter painter;

    QImage resultImage(rect.size(), QImage::Format_ARGB32_Premultiplied);

    painter.begin(&resultImage);
    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
    painter.eraseRect(rect);
    painter.drawImage(rect, resultImage);
    painter.end();

    painter.begin(&resultImage);
    painter.setCompositionMode(QPainter::CompositionMode_Darken);

    for(int i = 0; i < 765; i++)
    {
        if(i<256)
            painter.setPen(QPen(QColor(255, i, 0), 1));
        else if(i < 512)
            painter.setPen(QPen(QColor(511-i, 255, i-256), 1));
            else
                painter.setPen(QPen(QColor(i-512, 765-i, 255), 1));

        painter.drawLine(i, 0, i, 500);
    }
    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
    painter.drawImage(rect, resultImage);
    painter.end();

    l->setPixmap(QPixmap::fromImage(resultImage));
    l->show();

    QObject::connect( this, SIGNAL( closeSignal() ), l, SLOT( close() ) );
}
Пример #2
0
//Slot for the game help button
void Board::help()
{
    QLabel *instructions = new QLabel("                                    Game rules and instructions:\n                      Point the mouse curser in the direction you wish to shoot the bubble\n                      If the bubble forms a group with 3 or more same colour bubbles,\n                      they will be deleted and you will recieve points.");
    instructions->setWindowTitle("Bubble Shooter - Help");      //writes instruction and displayes them
    instructions->setFixedSize(400,200);
    instructions->show();
    qDebug("clicked Help");
}
Пример #3
0
void CGraphicMonth::pokazPomoc()
{   QFont font;
    font.setPointSize(mainFontSize+1);
    QLabel* pomocLabel = new QLabel(QString("Kalendarz pozwala na wyswietlanie oraz zmianę aktualnego miesiaca.\nPozwala również na dodawanie/usuwanie dni świątecznych poprzez kliknięcie w dany dzień."),this);
    pomocLabel->setFont(font);
    pomocLabel->setWindowTitle(QString("Pomoc kalendarza."));
    pomocLabel->setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::Dialog);
    pomocLabel->show();
}
Пример #4
0
void CmdTestRedirectPaint::activated(int iMsg)
{
    QCalendarWidget* cal = new QCalendarWidget();
    QLabel* label = new QLabel();
    QPainter::setRedirected(cal,label);
    cal->setWindowTitle(QString::fromAscii("QCalendarWidget"));
    cal->show();
    label->show();
    label->setWindowTitle(QString::fromAscii("QLabel"));
}
Пример #5
0
void displayData(const ComplexVector<T> &data, ImageSize size, const QString& title)
{
    std::vector<T> dataValue;
    int n0 = size.x;
    int n1 = size.y;
    int n2 = size.z;

    if (n2 < 2) n2 = 2;

    int nImages = 4;

    int start = (n0 * n1) * (n2 / 2 - 3);
    int end = (n0 * n1) * (n2 / 2 - 3 + nImages);

    for (auto it = data.begin() + start; it < data.begin() + end; it++) {
        float value = std::abs(*it);
        dataValue.push_back(value);
    }

    float max = *std::max_element(dataValue.begin(), dataValue.end());
    float min = *std::min_element(dataValue.begin(), dataValue.end());

    QImage dataImage(n1 * nImages, n0, QImage::Format_Indexed8);
    for (int i = 0; i < 256; i++) {
        dataImage.setColor(i, qRgb(i, i, i));
    }

    int i = 0;
    for (int y = 0; y < n0; y++) {
        auto imageLine = dataImage.scanLine(y);
        i = y * n1;
        for (int j = 0; j < nImages; j++)
        {
            for (int x = j * n0; x < j * n0 + n1; x++)
            {
                Q_ASSERT(i < dataValue.size());
                uint idx;
                if (max == min)
                    idx = 127;
                else
                    idx = (dataValue[i] - min) / (max - min) * 255;
                imageLine[x] = idx;
                i++;
            }
            i += n0 * (n1 - 1);
        }
    }

    QPixmap pixmap = QPixmap::fromImage(dataImage);

    QLabel *imgWnd = new QLabel("Image Window");
    imgWnd->setWindowTitle(title);
    imgWnd->setPixmap(pixmap);
    imgWnd->show();
}
Пример #6
0
int main(int argc, char *argv[])
{
    Application app(argc, argv);

    QEventLoop loop;

    auto s(std::async(std::launch::async, [&loop]{ Datum::Solve solve(Datum::solve()); if (loop.isRunning()) { loop.quit(); } return std::move(solve); }));

    QLabel splash;
    splash.setMovie(new QMovie(([](){
        static const QString basePath(":/splash/busy/");
        const QStringList files(QDir(basePath).entryList(QStringList() << "*.gif"));

        std::random_device rd;
        std::mt19937 gen(rd());

        std::uniform_int_distribution<> d(0,files.size() - 1);
        const QString& result(files.at(d(gen)));
        return basePath + result;
    })()));
    splash.movie()->start();
    splash.show();
    splash.setWindowTitle("computing. . .");

    if (s.wait_until(std::chrono::system_clock::now()) != std::future_status::ready) {
        loop.exec();
    }
    splash.hide();
    app.showBarley();

    Datum::Solve solve(s.get());

    Datum d;
    while (!solve.empty()) {
        Application::showDatum(d);
        d = d.realize(solve.top());
        solve.pop();
    }
    Application::showDatum(d, false);

    app.quit();
    return 0;
}
Пример #7
0
void displayData(int n0, int n1, const complexVector& data, const QString& title)
{
    QVector<float> dataValue;

    float max = 0;
    float min = FLT_MAX;

    for (auto cValue : data) {
        float value = std::abs(cValue);
        if (value > max) max = value;
        if (value < min) min = value;

        dataValue << value;
    }

    QImage dataImage(n1, n0, QImage::Format_Indexed8);
    for (int i = 0; i < 256; i++) {
        dataImage.setColor(i, qRgb(i, i, i));
    }

    int i = 0;
    for (int y = 0; y < n0; y++) {
        auto imageLine = dataImage.scanLine(y);

        for (int x = 0; x < n1; x++) {
            uint idx;
            if (max == min)
                idx = 127;
            else
                idx = (dataValue[i] - min) / (max - min) * 255;
            imageLine[x] = idx;
            i++;
        }
    }

    QPixmap pixmap = QPixmap::fromImage(dataImage);

    QLabel *imgWnd = new QLabel("Image Window");
    imgWnd->setWindowTitle(title);
    imgWnd->setPixmap(pixmap);
    imgWnd->show();
}
Пример #8
0
int main(int argc, char **argv)
{
#ifdef CONSOLE_APPLICATION
    QApplication app(argc, argv, QApplication::Tty);
#else
    QApplication app(argc, argv);
#endif
#ifdef DO_QWS_DEBUGGING
    qt_show_painter_debug_output = false;
#endif

    DeviceType type = WidgetType;
    bool checkers_background = true;

    QImage::Format imageFormat = QImage::Format_ARGB32_Premultiplied;

    QLocale::setDefault(QLocale::c());

    QStringList files;

    bool interactive = false;
    bool printdlg = false;
    bool highres = false;
    bool show_cmp = false;
    int width = 800, height = 800;
    bool verboseMode = false;

#ifndef QT_NO_OPENGL
    QGLFormat f = QGLFormat::defaultFormat();
    f.setSampleBuffers(true);
    f.setStencil(true);
    f.setAlpha(true);
    f.setAlphaBufferSize(8);
    QGLFormat::setDefaultFormat(f);
#endif

    char *arg;
    for (int i=1; i<argc; ++i) {
        arg = argv[i];
        if (*arg == '-') {
            QString option = QString(arg + 1).toLower();
            if (option == "widget")
                type = WidgetType;
            else if (option == "bitmap")
                type = BitmapType;
            else if (option == "pixmap")
                type = PixmapType;
            else if (option == "image")
                type = ImageType;
            else if (option == "imageformat") {
                Q_ASSERT_X(i + 1 < argc, "main", "-imageformat must be followed by a value");
                QString format = QString(argv[++i]).toLower();

                imageFormat = QImage::Format_Invalid;
                static const unsigned int formatCount =
                    sizeof(imageFormats) / sizeof(imageFormats[0]);
                for (int ff = 0; ff < formatCount; ++ff) {
                    if (QLatin1String(imageFormats[ff].name) == format) {
                        imageFormat = imageFormats[ff].format;
                        break;
                    }
                }

                if (imageFormat == QImage::Format_Invalid) {
                    printf("Invalid image format.  Available formats are:\n");
                    for (int ff = 0; ff < formatCount; ++ff) 
                        printf("\t%s\n", imageFormats[ff].name);
                    return -1;
                }
            } else if (option == "imagemono")
                type = ImageMonoType;
            else if (option == "imagewidget")
                type = ImageWidgetType;
#ifndef QT_NO_OPENGL
            else if (option == "opengl")
                type = OpenGLType;
            else if (option == "pbuffer")
                type = OpenGLPBufferType;
#endif
#ifdef USE_CUSTOM_DEVICE
            else if (option == "customdevice")
                type = CustomDeviceType;
            else if (option == "customwidget")
                type = CustomWidgetType;
#endif
            else if (option == "pdf")
                type = PdfType;
            else if (option == "ps")
                type = PsType;
            else if (option == "picture")
                type = PictureType;
            else if (option == "printer")
                type = PrinterType;
            else if (option == "highres") {
                type = PrinterType;
                highres = true;
            } else if (option == "printdialog") {
                type = PrinterType;
                printdlg = true;
            }
            else if (option == "grab")
                type = GrabType;
            else if (option == "i")
                interactive = true;
            else if (option == "v")
                verboseMode = true;
            else if (option == "commands") {
                displayCommands();
                return 0;
            } else if (option == "w") {
                Q_ASSERT_X(i + 1 < argc, "main", "-w must be followed by a value");
                width = atoi(argv[++i]);
            } else if (option == "h") {
                Q_ASSERT_X(i + 1 < argc, "main", "-h must be followed by a value");
                height = atoi(argv[++i]);
            } else if (option == "cmp") {
                show_cmp = true;
            } else if (option == "bg-white") {
                checkers_background = false;
            }
        } else {
#if defined (Q_WS_WIN)
            QString input = QString::fromLocal8Bit(argv[i]);
            if (input.indexOf('*') >= 0) {
                QFileInfo info(input);
                QDir dir = info.dir();
                QFileInfoList infos = dir.entryInfoList(QStringList(info.fileName()));
                for (int ii=0; ii<infos.size(); ++ii)
                    files.append(infos.at(ii).absoluteFilePath());
            } else {
                files.append(input);
            }
#else
            files.append(QString(argv[i]));
#endif
        }
    }

    PaintCommands pcmd(QStringList(), 800, 800);
    pcmd.setVerboseMode(verboseMode);
    pcmd.setType(type);
    pcmd.setCheckersBackground(checkers_background);

    QWidget *activeWidget = 0;

    if (interactive) {
        runInteractive();
        if (!files.isEmpty())
            interactive_widget->load(files.at(0));
    } else if (files.isEmpty()) {
        printHelp();
        return 0;
    } else {
        for (int j=0; j<files.size(); ++j) {
            const QString &fileName = files.at(j);
            QStringList content;

            QFile file(fileName);
            QFileInfo fileinfo(file);
            if (file.open(QIODevice::ReadOnly)) {
                QTextStream textFile(&file);
                QString script = textFile.readAll();
                content = script.split("\n", QString::SkipEmptyParts);
            } else {
                printf("failed to read file: '%s'\n", qPrintable(fileName));
                continue;
            }
            pcmd.setContents(content);

            if (show_cmp) {
                QString pmFile = QString(files.at(j)).replace(".qps", "_qps") + ".png";
                qDebug() << pmFile << QFileInfo(pmFile).exists();
                QPixmap pixmap(pmFile);
                if (!pixmap.isNull()) {
                    QLabel *label = createLabel();
                    label->setWindowTitle("VERIFY: " + pmFile);
                    label->setPixmap(pixmap);
                    label->show();
                }
            }

            switch (type) {

            case WidgetType:
            {
                OnScreenWidget<QWidget> *qWidget =
                    new OnScreenWidget<QWidget>;
                qWidget->setVerboseMode(verboseMode);
                qWidget->setType(type);
                qWidget->setCheckersBackground(checkers_background);
                qWidget->m_filename = files.at(j);
                qWidget->setWindowTitle(fileinfo.filePath());
                qWidget->m_commands = content;
                qWidget->resize(width, height);
                qWidget->show();
                activeWidget = qWidget;
                break;
            }

            case ImageWidgetType:
            {
                OnScreenWidget<QWidget> *qWidget = new OnScreenWidget<QWidget>;
                qWidget->setVerboseMode(verboseMode);
                qWidget->setType(type);
                qWidget->setCheckersBackground(checkers_background);
                qWidget->m_filename = files.at(j);
                qWidget->setWindowTitle(fileinfo.filePath());
                qWidget->m_commands = content;
                qWidget->resize(width, height);
                qWidget->show();
                activeWidget = qWidget;
                break;

            }
#ifndef QT_NO_OPENGL
            case OpenGLPBufferType:
            {
                QGLPixelBuffer pbuffer(QSize(width, height));
                QPainter pt(&pbuffer);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();

                QImage image = pbuffer.toImage();

                QLabel *label = createLabel();
                label->setPixmap(QPixmap::fromImage(image));
                label->resize(label->sizeHint());
                label->show();
                activeWidget = label;
                break;
            }
            case OpenGLType:
            {
                OnScreenWidget<QGLWidget> *qGLWidget = new OnScreenWidget<QGLWidget>;
                qGLWidget->setVerboseMode(verboseMode);
                qGLWidget->setType(type);
                qGLWidget->setCheckersBackground(checkers_background);
                qGLWidget->m_filename = files.at(j);
                qGLWidget->setWindowTitle(fileinfo.filePath());
                qGLWidget->m_commands = content;
                qGLWidget->resize(width, height);
                qGLWidget->show();
                activeWidget = qGLWidget;
                break;
            }
#else
            case OpenGLType:
                printf("OpenGL type not supported in this Qt build\n");
                break;
#endif
#ifdef USE_CUSTOM_DEVICE
            case CustomDeviceType:
            {
                CustomPaintDevice custom(width, height);
                QPainter pt;
                pt.begin(&custom);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();
                QImage *img = custom.image();
                if (img) {
                    QLabel *label = createLabel();
                    label->setPixmap(QPixmap::fromImage(*img));
                    label->resize(label->sizeHint());
                    label->show();
                    activeWidget = label;
                    img->save("custom_output_pixmap.png", "PNG");
                } else {
                    custom.save("custom_output_pixmap.png", "PNG");
                }
                break;
            }
            case CustomWidgetType:
            {
                OnScreenWidget<CustomWidget> *cWidget = new OnScreenWidget<CustomWidget>;
                cWidget->setVerboseMode(verboseMode);
                cWidget->setType(type);
                cWidget->setCheckersBackground(checkers_background);
                cWidget->m_filename = files.at(j);
                cWidget->setWindowTitle(fileinfo.filePath());
                cWidget->m_commands = content;
                cWidget->resize(width, height);
                cWidget->show();
                activeWidget = cWidget;
                break;
            }
#endif
            case PixmapType:
            {
                QPixmap pixmap(width, height);
                pixmap.fill(Qt::white);
                QPainter pt(&pixmap);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();
                pixmap.save("output_pixmap.png", "PNG");
                break;
            }

            case BitmapType:
            {
                QBitmap bitmap(width, height);
                QPainter pt(&bitmap);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();
                bitmap.save("output_bitmap.png", "PNG");

                QLabel *label = createLabel();
                label->setPixmap(bitmap);
                label->resize(label->sizeHint());
                label->show();
                activeWidget = label;
                break;
            }

            case ImageMonoType:
            case ImageType:
            {
                qDebug() << "Creating image";
                QImage image(width, height, type == ImageMonoType
                             ? QImage::Format_MonoLSB
                             : imageFormat);
                image.fill(0);
                QPainter pt(&image);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();
                image.convertToFormat(QImage::Format_ARGB32).save("output_image.png", "PNG");
#ifndef CONSOLE_APPLICATION
                QLabel *label = createLabel();
                label->setPixmap(QPixmap::fromImage(image));
                label->resize(label->sizeHint());
                label->show();
                activeWidget = label;
#endif
                break;
            }

            case PictureType:
            {
                QPicture pic;
                QPainter pt(&pic);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();

                QImage image(width, height, QImage::Format_ARGB32_Premultiplied);
                image.fill(0);
                pt.begin(&image);
                pt.drawPicture(0, 0, pic);
                pt.end();
                QLabel *label = createLabel();
                label->setWindowTitle(fileinfo.absolutePath());
                label->setPixmap(QPixmap::fromImage(image));
                label->resize(label->sizeHint());
                label->show();
                activeWidget = label;
                break;
            }

            case PrinterType:
            {
                PaintCommands pcmd(QStringList(), 800, 800);
                pcmd.setVerboseMode(verboseMode);
                pcmd.setType(type);
                pcmd.setCheckersBackground(checkers_background);
                pcmd.setContents(content);
                QString file = QString(files.at(j)).replace(".", "_") + ".ps";

                QPrinter p(highres ? QPrinter::HighResolution : QPrinter::ScreenResolution);
                if (printdlg) {
                    QPrintDialog printDialog(&p, 0);
                    if (printDialog.exec() != QDialog::Accepted)
                        break;
                } else {
                    p.setOutputFileName(file);
                }

                QPainter pt(&p);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();

                if (!printdlg) {
                    printf("wrote file: %s\n", qPrintable(file));
                }

                Q_ASSERT(!p.paintingActive());
                break;
            }
            case PsType:
            case PdfType:
            {
                PaintCommands pcmd(QStringList(), 800, 800);
                pcmd.setVerboseMode(verboseMode);
                pcmd.setType(type);
                pcmd.setCheckersBackground(checkers_background);
                pcmd.setContents(content);
                bool ps = type == PsType;
                QPrinter p(highres ? QPrinter::HighResolution : QPrinter::ScreenResolution);
                QFileInfo input(files.at(j));
                QString file = QString("%1_%2.%3")
                               .arg(input.baseName())
                               .arg(input.suffix())
                               .arg(ps ? "ps" : "pdf");
                p.setOutputFormat(ps ? QPrinter::PdfFormat : QPrinter::PostScriptFormat);
                p.setOutputFileName(file);
                p.setPageSize(QPrinter::A4);
                QPainter pt(&p);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();

                printf("write file: %s\n", qPrintable(file));
                break;
            }
            case GrabType:
            {
                QImage image(width, height, QImage::Format_ARGB32_Premultiplied);
                image.fill(QColor(Qt::white).rgb());
                QPainter pt(&image);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();
                QImage image1(width, height, QImage::Format_RGB32);
                image1.fill(QColor(Qt::white).rgb());
                QPainter pt1(&image1);
                pt1.drawImage(QPointF(0, 0), image);
                pt1.end();

                QString filename = QString(files.at(j)).replace(".qps", "_qps") + ".png";
                image1.save(filename, "PNG");
                printf("%s grabbed to %s\n", qPrintable(files.at(j)), qPrintable(filename));
                break;
            }

            default:
                break;
            }
        }
    }
#ifndef CONSOLE_APPLICATION
    if (activeWidget || interactive) {
        QObject::connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
        app.exec();
    }

    delete activeWidget;
#endif
    return 0;
}
Пример #9
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QPalette p;
    p.setColor(QPalette::Background, QColor("#97CBFF"));
    a.setPalette(p);
    //a.setAutoFillBackground(true);

    QLabel *window = new QLabel();
    window->setWindowTitle(TEXT_WINDOW_TITLE);

    QLabel *horCoordinate = new QLabel();
    QPixmap hCoord(PATH_HCOORD_IMG);
    horCoordinate->setPixmap(hCoord);
    horCoordinate->setMinimumSize(SIZE_COORDINATE_L, SIZE_COORDINATE_W);

    QLabel *verCoordinate = new QLabel();
    QPixmap vCoord(PATH_VCOORD_IMG);
    verCoordinate->setPixmap(vCoord);
    verCoordinate->setMinimumSize(SIZE_COORDINATE_W, SIZE_COORDINATE_L);

    Chessboard *chessboard = new Chessboard();
    QPixmap img(PATH_CHESSBORAD_IMG);
    chessboard->setPixmap(img.scaled(SIZE_CHESSBOARD, SIZE_CHESSBOARD));
    chessboard->setMinimumSize(SIZE_CHESSBOARD, SIZE_CHESSBOARD);

    QTextCodec *TradChineseCodec = QTextCodec::codecForName("Big5-ETen");
    QLabel *chessboardReadme = new QLabel(TradChineseCodec->toUnicode(
                                              "<center> <b>黑方</b> 滑鼠左鍵 |<b>  白方</b> 滑鼠右鍵 |<b>  清空</b> 滑鼠中鍵 </center>"));
    chessboardReadme->setAlignment(Qt::AlignHCenter);
    QLabel *funcReadme = new QLabel(TradChineseCodec->toUnicode(" <br> <br> <br> <br> <br><br> <br> <br> <br>"));

    QPushButton *clearBoard = new QPushButton(TradChineseCodec->toUnicode("清空棋盤"));
    QObject::connect(clearBoard, SIGNAL(clicked()), chessboard, SLOT(cleanChessboard()));
    QPushButton *readBoardData = new QPushButton(TradChineseCodec->toUnicode("讀取已存棋盤"));
    QObject::connect(readBoardData, SIGNAL(clicked()), chessboard, SLOT(readFromTxt()));
    QGridLayout *buttonLayout = new QGridLayout();
    buttonLayout->addWidget(readBoardData, 0, 0);
    buttonLayout->addWidget(clearBoard, 0, 1);

    QGridLayout *wholeChessboard = new QGridLayout;
    wholeChessboard->addWidget(horCoordinate, 0, 1);
    wholeChessboard->addWidget(verCoordinate, 1, 0);
    wholeChessboard->addWidget(chessboard, 1, 1);
    wholeChessboard->addWidget(chessboardReadme, 2, 0, 1, 2);
    wholeChessboard->addLayout(buttonLayout, 3, 0, 1, 2);
    wholeChessboard->addWidget(funcReadme, 4, 0, 1, 2);
    wholeChessboard->setMargin(20);


    FuncSet1 *findThreat = new FuncSet1();
    findThreat->setMinimumSize(SIZE_FUNC_W, SIZE_FUNC_H2);
    findThreat->setBrd(&(chessboard->boardData));

    FuncSet2 *threatSpaceSearch = new FuncSet2();
    threatSpaceSearch->setMinimumSize(SIZE_FUNC_W, SIZE_FUNC_H1);
    threatSpaceSearch->setBrd(&(chessboard->boardData));

    FuncSet3 *availableMove = new FuncSet3();
    availableMove->setMinimumSize(SIZE_FUNC_W, SIZE_FUNC_H2);
    availableMove->setBrd(&(chessboard->boardData));

    FuncSet4 *proofNumberSearch = new FuncSet4();
    proofNumberSearch->setMinimumSize(SIZE_FUNC_W, SIZE_FUNC_H1);
    proofNumberSearch->setBrd(&(chessboard->boardData));


    QGridLayout *wholeApp = new QGridLayout();
    wholeApp->addLayout(wholeChessboard,   0, 0, 3, 1);
    wholeApp->addWidget(availableMove,     0, 1);
    wholeApp->addWidget(findThreat,        1, 1);
    wholeApp->addWidget(threatSpaceSearch, 2, 1);
    wholeApp->addWidget(proofNumberSearch, 0, 2, 3, 1);
    wholeApp->setSpacing(15);


    QObject::connect(chessboard, SIGNAL(changeFuncsTurn(int)), availableMove,     SLOT(changeTurn(int)));
    QObject::connect(chessboard, SIGNAL(changeFuncsTurn(int)), findThreat,        SLOT(changeTurn(int)));
    QObject::connect(chessboard, SIGNAL(changeFuncsTurn(int)), threatSpaceSearch, SLOT(changeTurn(int)));
    QObject::connect(chessboard, SIGNAL(changeFuncsTurn(int)), proofNumberSearch, SLOT(changeTurn(int)));

    //wholeChessboard->addWidget(test, 4, 0, 1, 2);
    /*Paper *ya = new Paper();
    wholeApp->addWidget(ya, 2,2);

    BoardData orig;
    orig.printBoard(ya);
    orig.set(0,0,BLACK);
    orig.set(0,1,WHITE);
    orig.printBoard(ya);
    BoardData *tmp = new BoardData(&orig);
    tmp->set(1,1,BLACK);
    tmp->printBoard(ya);
    orig.printBoard(ya);*/

    window->setLayout(wholeApp);


    // 把其他method也寫進去

    // 以上先以"測試階段"的感覺去寫
    // last step: 整理code 還有output

    // threatspaceSearch 23

    window->show();
    return a.exec();
}
Пример #10
0
void Utils::show(QString title, QImage* img){
    QLabel label;
    label.setPixmap(QPixmap::fromImage(*img));
    label.setWindowTitle(title);
    label.show();
}