void LyxWidget::insertLyxInMainWidget(lyx::frontend::GuiView* mainWindow) { LyxGlobal::setLyxWindow(mainWindow); QWidget *lyxWindow = (QWidget*)mainWindow;//Окно LyX QWidget *mainWidget = widgetInstance;//Окно системы QLayout *l = new QVBoxLayout(mainWidget); l->addWidget(lyxWindow); mainWidget->setLayout(l); lyxWindow->connect(mainWindow, SIGNAL(closed()), widgetInstance, SIGNAL(lyxClosed())); }
static int openWindow(const cv::Mat_<cv::Vec3b>& image) { char *argv[1] = { 0 }; int argc = 0; QApplication app(argc, argv); QWidget *window = new QWidget; QVBoxLayout *layout = new QVBoxLayout; // adapted from http://www.qtcentre.org/threads/11655-OpenCV-integration cv::Mat rgb = image; std::vector<cv::Mat> channels; cv::split(rgb, channels); // split the image into r, g, b channels cv::Mat alpha = cv::Mat_<uchar>(image.size()); alpha.setTo(cv::Scalar(255)); channels.push_back(alpha); cv::Mat rgba = cv::Mat_<cv::Vec4b>(image.size()); cv::merge(channels, rgba); // add an alpha (so the image is r, g, b, a IplImage iplImage = (IplImage) rgba; // get the raw bytes const unsigned char *imageData = (unsigned char *)(iplImage.imageData); QImage qimage(imageData, iplImage.width, iplImage.height, iplImage.widthStep, QImage::Format_RGB32); // and convert to a QImage QLabel *imageFrame = new QLabel; imageFrame->setPixmap(QPixmap::fromImage(qimage, 0)); QPushButton *quit = new QPushButton(QString("Quit")); quit->setGeometry(62, 40, 75, 30); quit->setFont(QFont("Times", 18, QFont::Bold)); window->connect(quit, SIGNAL(clicked()), &app, SLOT(quit())); layout->addWidget(new QLabel("top")); layout->addWidget(imageFrame); layout->addWidget(new QLabel("bottom")); layout->addWidget(quit); window->setLayout(layout); window->setWindowTitle(QString("Qt Image Display")); window->show(); return app.exec(); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); const QString app_name("timecop"); const QString app_version("1.1"); const QString app_settings_dir(QDir::home().filePath(".timecop")); app.setOrganizationName("Daimler AG RD-DDA"); app.setApplicationName(app_name); QSettings::setDefaultFormat(QSettings::IniFormat); QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, app_settings_dir); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); QObject *root = 0; QWidget *rootWindow = 0; SystrayHelper systrayHelper; engine.rootContext()->setContextProperty("systrayHelper", &systrayHelper); engine.rootContext()->setContextProperty("app_name", app_name); engine.rootContext()->setContextProperty("app_version", app_version); engine.rootContext()->setContextProperty("app_settings_dir", app_settings_dir); if (engine.rootObjects().size() > 0) { root = engine.rootObjects().at(0); systrayHelper.setRootWindow(root); if(root->isWindowType()){ rootWindow = qobject_cast<QWidget*>(root); QApplication::setQuitOnLastWindowClosed(false); QAction *minimizeAction = new QAction(QObject::tr("Mi&nimize"), rootWindow); rootWindow->connect(minimizeAction, SIGNAL(triggered()), root, SLOT(hide())); QAction *maximizeAction = new QAction(QObject::tr("Ma&ximize"), rootWindow); rootWindow->connect(maximizeAction, SIGNAL(triggered()), root, SLOT(showMaximized())); QAction *restoreAction = new QAction(QObject::tr("&Restore"), rootWindow); rootWindow->connect(restoreAction, SIGNAL(triggered()), root, SLOT(showNormal())); QAction *quitAction = new QAction(QObject::tr("&Quit"), rootWindow); rootWindow->connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); QMenu *trayIconMenu = new QMenu(rootWindow); trayIconMenu->addAction(minimizeAction); trayIconMenu->addAction(maximizeAction); trayIconMenu->addAction(restoreAction); trayIconMenu->addSeparator(); trayIconMenu->addAction(quitAction); QSystemTrayIcon *trayIcon = new QSystemTrayIcon(rootWindow); QIcon icon(":/trayicon.png"); icon.setIsMask(true); //trayIcon->setContextMenu(trayIconMenu); trayIcon->setIcon(icon); trayIcon->setToolTip("Click to open"); trayIcon->setVisible(true); systrayHelper.setTrayIcon(trayIcon); QObject::connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), &systrayHelper, SLOT(activatedSystray(QSystemTrayIcon::ActivationReason))); trayIcon->show(); } } return app.exec(); }
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem & /* option */, const QModelIndex &index) const override { RemuxEntryState state = index.model() ->index(index.row(), RemuxEntryColumn::State) .data(RemuxEntryRole::EntryStateRole) .value<RemuxEntryState>(); if (state == RemuxEntryState::Pending || state == RemuxEntryState::InProgress) { // Never allow modification of rows that are // in progress. return Q_NULLPTR; } else if (isOutput && state != RemuxEntryState::Ready) { // Do not allow modification of output rows // that aren't associated with a valid input. return Q_NULLPTR; } else if (!isOutput && state == RemuxEntryState::Complete) { // Don't allow modification of rows that are // already complete. return Q_NULLPTR; } else { QSizePolicy buttonSizePolicy( QSizePolicy::Policy::Minimum, QSizePolicy::Policy::Expanding, QSizePolicy::ControlType::PushButton); QWidget *container = new QWidget(parent); auto browseCallback = [this, container]() { const_cast<RemuxEntryPathItemDelegate *>(this) ->handleBrowse(container); }; auto clearCallback = [this, container]() { const_cast<RemuxEntryPathItemDelegate *>(this) ->handleClear(container); }; QHBoxLayout *layout = new QHBoxLayout(); layout->setMargin(0); layout->setSpacing(0); QLineEdit *text = new QLineEdit(); text->setObjectName(QStringLiteral("text")); text->setSizePolicy(QSizePolicy( QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Expanding, QSizePolicy::ControlType::LineEdit)); layout->addWidget(text); QToolButton *browseButton = new QToolButton(); browseButton->setText("..."); browseButton->setSizePolicy(buttonSizePolicy); layout->addWidget(browseButton); container->connect(browseButton, &QToolButton::clicked, browseCallback); // The "clear" button is not shown in output cells // or the insertion point's input cell. if (!isOutput && state != RemuxEntryState::Empty) { QToolButton *clearButton = new QToolButton(); clearButton->setText("X"); clearButton->setSizePolicy(buttonSizePolicy); layout->addWidget(clearButton); container->connect(clearButton, &QToolButton::clicked, clearCallback); } container->setLayout(layout); container->setFocusProxy(text); return container; } }