void SwitchMonitor::initOneScreenMode(){
    // for one-screen mode
    for (int i = 0, length = m_ScreenList.length(); i < length; i++) {
        // one-screen mode item
        QWidget *item = new QWidget(m_MonitersWrapper);
        QVBoxLayout *vLayout = new QVBoxLayout(item);
        // image label for one-screen mode
        QSvgWidget *imageSvg = new QSvgWidget(item);
        imageSvg->setFixedSize(IMAGE_SIZE, IMAGE_SIZE);
        QLabel* imageLabel = new QLabel(item);
        imageLabel->setFixedSize(IMAGE_SIZE, IMAGE_SIZE);
        showThemeImage(getThemeIconPath("project_screen-onlyone-symbolic"), imageSvg, imageLabel);
        // text label for one-screen mode
        QLabel *textLabel = new QLabel(item);
        textLabel->setText(m_ScreenList[i]);
        textLabel->setAlignment(Qt::AlignCenter);
        textLabel->setStyleSheet(MONITOR_TEXT_NORMAL_STYLE);
        // store imagelabel and textlabel into lists, so that we can change their style later
        m_ImageSvgList << imageSvg;
        m_ImageLabelList << imageLabel;
        m_TextLabelList << textLabel;
        // add above 2 widgets
        if(getThemeIconPath("project_screen-onlyone-symbolic").endsWith(".svg")){
            vLayout->addWidget(imageSvg, 0, Qt::AlignHCenter);
        }else{
            vLayout->addWidget(imageLabel, 0, Qt::AlignHCenter);
        }
        vLayout->addWidget(textLabel, 0, Qt::AlignHCenter);

        m_HBoxLayout->addWidget(item);
    }
}
示例#2
0
static int 
qsvgwidget_renderer(lua_State *L)
{
  QSvgWidget *w = luaQ_checkqobject<QSvgWidget>(L, 1);
  luaQ_pushqt(L, w->renderer());
  return 1;
}
示例#3
0
文件: main.cpp 项目: langr-org/langr
/**
 * argv[1]: infile
 * argv[2]: outfile
 */
int main(int argc, char * argv[])
{
	QApplication app(argc, argv);
	QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030"));

	bool output = false;
	QString infile;
	QString outfile;
	
	if ( argc > 2 ) {
		outfile = QString(argv[2]);
	}
	if ( argc > 1 ) {
		infile = QString(argv[1]);
	}
	if ( infile.isEmpty() ) {
		printf("empty infile.");
		help();
		return -1;
	}

	if ( outfile.isEmpty() ) {
		outfile = "stdout.png";
		output = true;
	}

	QSvgWidget * svg = new QSvgWidget(0);
	svg->load(infile);
	svg->resize(800, 400);
	/*  */
	QPixmap pixmap = QPixmap();
	pixmap = QPixmap::grabWidget((QWidget*)svg);

	if ( output ) {
		QByteArray bytes;
		QBuffer buf(&bytes);
		buf.open(QIODevice::ReadWrite);
		pixmap.save(&buf, "PNG");
		printf(buf.data().data());
		exit(0);
	} else {
		pixmap.save(outfile);
	}

	return app.exec();
}
void ProxyConfigWidget::layoutElements()
{
    QFormLayout *fLayout = new QFormLayout();
    fLayout->addRow(tr("Proxy type:"), proxyType);
    fLayout->addRow(tr("Proxy host:"), proxyHost);
    fLayout->addRow(tr("Proxy port:"), proxyPort);
    fLayout->addRow(tr("Username:"******"Password:"******":/images/web.svg");
    pic->setFixedSize(100,100);

    hLayout->addWidget(pic);
    this->setLayout(hLayout);
}
示例#5
0
int main(int argc, char *argv[]) {

    QApplication app(argc, argv);
    app.setOrganizationName("QtProject");
    app.setApplicationName("Application Example");

    initDb();
    
    QMainWindow mainWin;
    mainWin.show();
    // QPlainTextEdit* textEdit = new QPlainTextEdit();
//    QToolBar* fileToolBar = mainWin.addToolBar("File");

    QSvgWidget* mySvg = new QSvgWidget();

    vector<string> students(10);
    students = { "eins", "zwei", "drei" };
    StudentList *studentListW = new StudentList(students);


    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addWidget(studentListW);
    mainLayout->addWidget(mySvg);

    QWidget *centralWidget = new QWidget;
    centralWidget->setLayout(mainLayout);

    mainWin.setCentralWidget(centralWidget);


    mySvg->load(QString(RESOURCES_PATH "zeugnis.svg"));
    QFile file(QString(RESOURCES_PATH "zeugnis.svg"));
    QDomDocument document;
    file.open(QIODevice::ReadOnly | QIODevice::Text);
    document.setContent(&file);

    QDomElement root = document.firstChildElement();
    QDomNodeList nodes = root.elementsByTagName("tspan");
    
    for(int i = 0; i < nodes.count(); i++) {
        QDomNode elm = nodes.at(i);
        if(elm.isElement()) {
            QDomElement element = elm.toElement();
            QString attribute = element.attribute("id");
            if(attribute == "tspan4167") {
                QString elementText = element.text();    
                std::cout << elementText.toStdString() << std::endl;

                QDomText newTextNode = document.createTextNode("Hello, World");
                QDomNodeList oldTextNodes = element.childNodes();
                qDebug() << "# nodes = " << oldTextNodes.count();
                for (int i=0; i < oldTextNodes.count(); i++) {
                    // element.removeChild(oldTextNodes.at(i));
                    qDebug() << oldTextNodes.at(i).toElement().text();
                }

                element.appendChild(newTextNode);
            }
        }
    }

    mySvg->load(document.toByteArray());

    file.close();
    return app.exec();
}