예제 #1
0
파일: main_window.cpp 프로젝트: gz818/itest
void MainWindow::setCurrentQuestion()
{
     if (LQListWidget->currentIndex().isValid()) {
        questionTextBrowser->clear();
        answersView->setEnabled(true);
        QuestionItem *item = current_test_questions.value(LQListWidget->currentItem());
        questionTextBrowser->setHtml(item->text());
        answersView->setAnswers(item->answers(), item->answered(), item->selectionType(), item->answerOrder());
        svgDisplayWidget->clear();
        if (item->numSvgItems() > 0) {
            svgDisplayWidget->setVisible(true);
            //int h = 0;
            for (int i = 0; i < item->numSvgItems(); ++i) {
                QSvgWidget *svg_widget = new QSvgWidget;
                QSize minimum_size = svg_widget->sizeHint();
                minimum_size.scale(128, 128, Qt::KeepAspectRatioByExpanding);
                svg_widget->setMinimumSize(minimum_size);
                svg_widget->load(item->svg(i).toUtf8());
                /*if (svg_widget->renderer()->defaultSize().height() + 40 > h) {
                    h = svg_widget->renderer()->defaultSize().height() + 40;
                }*/
                svgDisplayWidget->addWidget(svg_widget, item->svgName(i), true);
            }
            //if (h < 168) { h = 168; }
            qApp->processEvents();
            questionTextSvgSplitter->moveSplitter(questionTextSvgSplitter->height()-svgDisplayWidget->layoutHeightForWidth(questionTextSvgSplitter->width()));
        } else {
            svgDisplayWidget->setVisible(false);
        }
        if (LQListWidget->currentRow() >= (LQListWidget->count()-1)) {
            btnNext->setEnabled(false);
        } else {
            btnNext->setEnabled(true);
        }
        if (LQListWidget->currentRow() <= 0) {
            btnLast->setEnabled(false);
        } else {
            btnLast->setEnabled(true);
        }
     } else {
        questionTextBrowser->clear();
        answersView->clear();
        answersView->setEnabled(false);
        svgDisplayWidget->clear();
        btnNext->setEnabled(false);
        btnLast->setEnabled(false);
     }
}
예제 #2
0
파일: main_window.cpp 프로젝트: gz818/itest
void MainWindow::previewSvg(const QString &link)
{
    if (!LQListWidget->currentIndex().isValid())
        return;
    QuestionItem *item = current_test_questions.value(LQListWidget->currentItem());
    if (item == NULL)
        return;
    int i_link = link.toInt();
    if (i_link < 0 || i_link >= item->numSvgItems())
        return;
    QSvgWidget *svg_widget = new QSvgWidget;
    svg_widget->setAttribute(Qt::WA_DeleteOnClose);
    svg_widget->setParent(this);
#ifndef Q_OS_MAC
    svg_widget->setWindowFlags(Qt::Dialog | Qt::WindowMaximizeButtonHint | Qt::WindowStaysOnTopHint);
#else
    svg_widget->setWindowFlags(Qt::Dialog | Qt::WindowMaximizeButtonHint | Qt::WindowStaysOnTopHint | Qt::WindowSystemMenuHint);
#endif
    svg_widget->setWindowTitle(item->svgName(i_link));
    QSize minimum_size = svg_widget->sizeHint();
    minimum_size.scale(128, 128, Qt::KeepAspectRatioByExpanding);
    svg_widget->setMinimumSize(minimum_size);
    svg_widget->load(item->svg(i_link).toUtf8());
    svg_widget->show();
}