当前位置: 首页>>代码示例>>C++>>正文


C++ QGraphicsScene::addWidget方法代码示例

本文整理汇总了C++中QGraphicsScene::addWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ QGraphicsScene::addWidget方法的具体用法?C++ QGraphicsScene::addWidget怎么用?C++ QGraphicsScene::addWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QGraphicsScene的用法示例。


在下文中一共展示了QGraphicsScene::addWidget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc,char **argv) {
	QApplication app(argc,argv);

	QGraphicsScene scene;
	// 要把widget嵌入到QGraphicsScene內,必需要透過QGraphicsProxyWidget才可以
	// addWidget回傳的是QGraphicsProxyWidget,由QGraphicsWidget繼承
	QGraphicsWidget *textEdit = scene.addWidget(new QTextEdit);
	QGraphicsWidget *pushButton = scene.addWidget(new QPushButton);

	QGraphicsGridLayout *layout = new QGraphicsGridLayout;
	// QGraphicsGridLayout的addItem函數必需是QGraphicsWidget
	layout->addItem(textEdit, 0, 0);
	layout->addItem(pushButton, 0, 1);

	QGraphicsWidget *form = new QGraphicsWidget;
	form->setLayout(layout);
	scene.addItem(form);

	QGraphicsView view(&scene);

	view.show();


	return app.exec();
}
开发者ID:nightfly19,项目名称:renyang-learn,代码行数:25,代码来源:main.cpp

示例2: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QGraphicsScene scene;
    QGraphicsView view(&scene);

    // Add a Widget
    WidgetLoader *loader = new WidgetLoader;
    scene.addWidget(loader);

    //Add a second one and move to right side
    AnalogClock *clock = new AnalogClock;
    clock->move(QPoint(300,0));
    scene.addWidget(clock);

    //Finally the sampleWidget
    SampleWidget *widget = new SampleWidget;
    widget->move(0,300);
    scene.addWidget(widget);


    //Place a qml Widget
    QDeclarativeView *qmlView = new QDeclarativeView;
    qmlView->setSource(QUrl::fromLocalFile("qml/QMLBusTimetable.qml"));
    scene.addWidget(qmlView);
    qmlView->move(300,300);

    view.showMaximized();
    //Fullscreen:
//     view.showFullScreen();

    return a.exec();
}
开发者ID:pknierim,项目名称:WidgetCollection,代码行数:33,代码来源:main.cpp

示例3: loadGuiInitial

	void ARehabMainWindow::loadGuiInitial(void)
	{
		float wGraphicsView = ui.graphicsInicial->width();
		float hGraphicsView = ui.graphicsInicial->height();

		ui.btHelp->setIcon(QPixmap(QString::fromUtf8(":/svg/help.svg")));
		ui.btAbout->setIcon(QPixmap(QString::fromUtf8(":/svg/about.svg")));

		ui.graphicsInicial->verticalScrollBar()->blockSignals(true);
		ui.graphicsInicial->horizontalScrollBar()->blockSignals(true);
		ui.graphicsInicial->setScene(new QGraphicsScene);
		QGraphicsScene * scene = ui.graphicsInicial->scene();
		scene->setSceneRect(0, 0, ui.graphicsInicial->width(), ui.graphicsInicial->height());

		QRadialGradient gradient(wGraphicsView / 2.0f, hGraphicsView / 2.0f, hGraphicsView);
		gradient.setColorAt(0.95, QColor(200, 200, 200));
		gradient.setColorAt(0.5, QColor(255, 255, 255));
		gradient.setColorAt(0, QColor(255, 255, 255));
		scene->setBackgroundBrush(QBrush(gradient));

		QPixmap pix1(":/images/banner.png");
		this->pixmapItemInitial = scene->addPixmap(pix1);

		float wImage = this->pixmapItemInitial->boundingRect().width();
		float hImage = this->pixmapItemInitial->boundingRect().height();
		float scaleH = hGraphicsView / hImage;

		pixmapItemInitial->setTransformationMode(Qt::SmoothTransformation);
		pixmapItemInitial->setScale(scaleH);
		pixmapItemInitial->setPos((wGraphicsView / 2.0f) - (scaleH*wImage / 2.0f), 0);

		QFont btFont("Calibri", 16, QFont::Light);

		btNew = new QPushButton("Nuevo Ejercicio");
		btNew->setMinimumSize(360, 60);
		btNew->setFont(btFont);
		proxyBtNuevo = scene->addWidget(btNew);

		btLoad = new QPushButton("Cargar Ejercicio");
		btLoad->setMinimumSize(360, 60);
		btLoad->setFont(btFont);
		proxyBtLoad = scene->addWidget(btLoad);

		btLoadResults = new QPushButton("Cargar Resultados de Paciente");
		btLoadResults->setMinimumSize(360, 60);
		btLoadResults->setFont(btFont);
		proxyBtLoadResults = scene->addWidget(btLoadResults);

		QGridLayout * layoutBottomFrame = reinterpret_cast<QGridLayout*>(ui.bottomFrame->layout());
		if (layoutBottomFrame)
		{
			layoutBottomFrame->addWidget(this->guistatewidget, 0, 1);
			this->guistatewidget->hide();
		}
	}
开发者ID:JJ,项目名称:ARehab,代码行数:55,代码来源:ARehab_vTerapeuta.cpp

示例4: QWidget

MainWindow::MainWindow(QWidget *parent)
    : QWidget(parent)
{
    // create a scene with items,
    // use the view to show the scene
    QGraphicsScene *scene = new QGraphicsScene();
    QGraphicsView *gv = new QGraphicsView(this);
    gv->setScene(scene);
    if (gv->scene())
    {
        printf("renc: scene is not null.\n");

        // these two lines are at scene origin pos.
        scene->addLine(0, 0, 100, 0, QPen(Qt::red));
        scene->addLine(0, 0, 0, 100, QPen(Qt::green));

        /*QGraphicsRectItem *rect = */
        scene->addRect(QRectF(0,0,50,50), QPen(Qt::red), QBrush(Qt::green));

        // svg image
        QGraphicsSvgItem *svgItem = new QGraphicsSvgItem(svgFile2);
        scene->addItem((svgItem));
        svgItem->setPos(400, 0);
        bool rValid1 = svgItem->renderer()->isValid();
        printf("--%d--\n", rValid1);

        // QWidget to scene
        QPushButton *btn = new QPushButton("button 1");// at (0,0) by default.
        QGraphicsProxyWidget *btnWidget = scene->addWidget(btn);
        btnWidget->setPos(0, 400);

        //
        {
            SvgPushButton *btn2 = new SvgPushButton(svgFile1);
            QGraphicsProxyWidget *btnWidget2 = scene->addWidget(btn2);
            btnWidget2->setPos(400, 400);
        }
    }
    else
        printf("renc: scene is null.\n");

    //setCentralWidget(gv); setWindowTitle("Demo: graphics view");//QMainWindow
    setStyleSheet("background-color: rgb(100,120,50);");
}
开发者ID:renc,项目名称:coding_exercises,代码行数:44,代码来源:mainwindow.cpp

示例5: main

//! [0]
int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    QTabWidget *tabWidget = new QTabWidget;

    QGraphicsScene scene;
    QGraphicsProxyWidget *proxy = scene.addWidget(tabWidget);

    QGraphicsView view(&scene);
    view.show();

    return app.exec();
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:15,代码来源:src_gui_graphicsview_qgraphicsproxywidget.cpp

示例6: pix

GraphicsView::GraphicsView(QWidget *parent) :
    QGraphicsView(parent), warringLine(NULL), viewRect(NULL)
{
    QGraphicsScene *s = new QGraphicsScene(this);
    this->setScene(s);

    s->addRect(0, 0, 10, 10);

    menu = s->addWidget(new VehicleTypeMenu(this));

    QPixmap pix("./icon/compass.png");
    compass = s->addPixmap(pix.scaled(200, 200));
    compass->setZValue(100);
}
开发者ID:ChenMingHe,项目名称:vanet_map_app,代码行数:14,代码来源:graphicsview.cpp

示例7: QGraphicsView

/*!
    \brief The constructor initializes everything needed for the 3D animation.
 */
AboutDialogGraphicsView::AboutDialogGraphicsView(AboutDialog *aboutDialog, QWidget *parentWindow) : QGraphicsView(parentWindow)
	, _aboutDialog(NULL)
	, _graphicsProxyWidget(NULL)
	, _parentWindow(NULL)
	, _timeLine(NULL)
	, _aboutDialogAsSplashScreen(NULL)
{
    _parentWindow = parentWindow;
    setWindowFlags(Qt::SplashScreen);

#ifdef Q_OS_LINUX
    QRect availableGeometry = QApplication::desktop()->availableGeometry();
    QRect newGeometry = QRect( availableGeometry.x(), availableGeometry.y(), availableGeometry.width(), availableGeometry.height() );
#else
    QRect newGeometry = QRect( -1,-1, QApplication::desktop()->rect().width()+2, QApplication::desktop()->rect().height()+2 );
#endif
    setGeometry( newGeometry );

    _aboutDialog = aboutDialog;

    _windowTitleBarWidth = 0;
    _windowPosOffset = 0;

    QGraphicsScene *scene = new QGraphicsScene(this);
    setSceneRect( newGeometry );
    _aboutDialogAsSplashScreen = new QSplashScreen(this);
    _graphicsProxyWidget = scene->addWidget(_aboutDialogAsSplashScreen);
    _graphicsProxyWidget->setWindowFlags( Qt::ToolTip );

    setScene( scene );
    setRenderHint(QPainter::Antialiasing);

    setCacheMode(QGraphicsView::CacheBackground);
    setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);

    connect(_aboutDialog, SIGNAL(finished(int)), this, SLOT(hide()));

    //setWindowOpacity(0.9);

    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setStyleSheet("AboutDialogGraphicsView { border: 0px; }");

    _timeLine = new QTimeLine(1000, this);
    _timeLine->setFrameRange(270, 0);
    //_timeLine->setUpdateInterval(10);
    //_timeLine->setCurveShape(QTimeLine::EaseInCurve);
    connect(_timeLine, SIGNAL(frameChanged(int)), this, SLOT(updateStep(int)));
}
开发者ID:Coder-666,项目名称:UniversalIndentGUI,代码行数:52,代码来源:AboutDialogGraphicsView.cpp

示例8: init

    static void init(QGraphicsView *view)
    {
        QGroupBox *groupBox = new QGroupBox("Contact Details");
        QLabel *numberLabel = new QLabel("Telephone number");
        QLineEdit *numberEdit = new QLineEdit;

        QFormLayout *layout = new QFormLayout;
        layout->addRow(numberLabel, numberEdit);
        groupBox->setLayout(layout);

        QGraphicsScene *scene = new QGraphicsScene;
        scene->addWidget(groupBox);

        view->setScene(scene);
    }
开发者ID:agamez,项目名称:qt-x11-maemo,代码行数:15,代码来源:display.cpp

示例9: QGraphicsView

JournalGUI_ExerciseCard::JournalGUI_ExerciseCard( QWidget* theParent )
  : QGraphicsView( theParent )
{
  myShrink = 0.8;
  myDelta = -10;
  myShadowColor = QColor( 64, 64, 64, 200 );
  myBlurRadius = 20;
  myIsFinished = false;

  QGraphicsScene* aScene = new QGraphicsScene( this );
  setScene( aScene );
  
  setWindowFlags( Qt::Window | Qt::FramelessWindowHint );
  setAttribute( Qt::WA_TranslucentBackground );
  setFrameShape( QFrame::NoFrame );

  myShadowItem = new QGraphicsRectItem();
  myShadowItem->setBrush( myShadowColor );
  QGraphicsBlurEffect* aBlur = new QGraphicsBlurEffect( this );
  aBlur->setBlurRadius( myBlurRadius );
  myShadowItem->setGraphicsEffect( aBlur );
  aScene->addItem( myShadowItem );

  QFrame* aMainFrame = new QFrame( 0 );
  QVBoxLayout* aLayout = new QVBoxLayout( aMainFrame );

  QGridLayout* aMainLayout = new QGridLayout( 0 );
  QHBoxLayout* aStatusLayout = new QHBoxLayout( 0 );
  aLayout->addLayout( aMainLayout, 1 );
  aLayout->addLayout( aStatusLayout, 0 );

  myStateLabel = new QLabel( "", this );
  aStatusLayout->addWidget( myStateLabel, 1 );

  myVerify = new QPushButton( tr( "Verify" ), this );
  connect( myVerify, SIGNAL( clicked() ), this, SLOT( OnFinish() ) );
  aStatusLayout->addWidget( myVerify, 0 );

  myNext = new QPushButton( tr( "Next" ), this );
  connect( myNext, SIGNAL( clicked() ), this, SIGNAL( next() ) );
  aStatusLayout->addWidget( myNext, 0 );
  
  aMainLayout->setColumnStretch( 0, 1 );
  aMainLayout->setRowStretch( MAX_NB_ROWS, 1 );

  myFrameItem = aScene->addWidget( aMainFrame );
}
开发者ID:alexandre-solovyov,项目名称:journal,代码行数:47,代码来源:JournalGUI_ExerciseCard.cpp

示例10: QPixmap

FxLine::FxLine( QWidget * _parent, FxMixerView * _mv, int _channelIndex ) :
	QWidget( _parent ),
	m_mv( _mv ),
	m_channelIndex( _channelIndex ),
	m_backgroundActive( Qt::SolidPattern ),
	m_strokeOuterActive( 0, 0, 0 ),
	m_strokeOuterInactive( 0, 0, 0 ),
	m_strokeInnerActive( 0, 0, 0 ),
	m_strokeInnerInactive( 0, 0, 0 ),
	m_inRename( false )
{
	if( !s_sendBgArrow )
	{
		s_sendBgArrow = new QPixmap( embed::getIconPixmap( "send_bg_arrow", 29, 56 ) );
	}
	if( !s_receiveBgArrow )
	{
		s_receiveBgArrow = new QPixmap( embed::getIconPixmap( "receive_bg_arrow", 29, 56 ) );
	}

	setFixedSize( 33, FxLineHeight );
	setAttribute( Qt::WA_OpaquePaintEvent, true );
	setCursor( QCursor( embed::getIconPixmap( "hand" ), 3, 3 ) );

	// mixer sends knob
	m_sendKnob = new Knob( knobBright_26, this, tr( "Channel send amount" ) );
	m_sendKnob->move( 3, 22 );
	m_sendKnob->setVisible( false );

	// send button indicator
	m_sendBtn = new SendButtonIndicator( this, this, m_mv );
	m_sendBtn->move( 2, 2 );

	// channel number
	m_lcd = new LcdWidget( 2, this );
	m_lcd->setValue( m_channelIndex );
	m_lcd->move( 4, 58 );
	m_lcd->setMarginWidth( 1 );
	
	QString name = Engine::fxMixer()->effectChannel( m_channelIndex )->m_name;
	setToolTip( name );

	m_renameLineEdit = new QLineEdit();
	m_renameLineEdit->setText( name );
	m_renameLineEdit->setFixedWidth( 65 );
	m_renameLineEdit->setFont( pointSizeF( font(), 7.5f ) );
	m_renameLineEdit->setReadOnly( true );
	m_renameLineEdit->installEventFilter( this );

	QGraphicsScene * scene = new QGraphicsScene();
	scene->setSceneRect( 0, 0, 33, FxLineHeight );

	m_view = new QGraphicsView( this );
	m_view->setStyleSheet( "border-style: none; background: transparent;" );
	m_view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
	m_view->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
	m_view->setAttribute( Qt::WA_TransparentForMouseEvents, true );
	m_view->setScene( scene );

	QGraphicsProxyWidget * proxyWidget = scene->addWidget( m_renameLineEdit );
	proxyWidget->setRotation( -90 );
	proxyWidget->setPos( 8, 145 );

	connect( m_renameLineEdit, SIGNAL( editingFinished() ), this, SLOT( renameFinished() ) );
}
开发者ID:JohannesLorenz,项目名称:lmms,代码行数:65,代码来源:FxLine.cpp

示例11: QGraphicsView

PreviewWidget::PreviewWidget(QWidget* parent)
             : QGraphicsView(parent), d(new PreviewWidgetPriv)
{
    QString whatsThis = i18n("<p>This widget will display a correction "
            "preview for the currently selected image</p>"
            "<p><ul>"
            "<li>Move the mouse <b>over</b> the preview to display the original image</li>"
            "<li>Move the mouse <b>out of</b> the preview to display the corrected image</li>"
            "<li><b>Click on</b> the preview to display the correction mask</li>"
            "</ul></p>"
            "<p>The zoom buttons and panning widget allow you to view certain parts of the image "
            "more closely.</p>");

    setWhatsThis(whatsThis);

    // --------------------------------------------------------

    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    setCacheMode(QGraphicsView::CacheBackground);

    // --------------------------------------------------------

    d->locked               = true;

    d->busyLabel            = new QLabel;
    d->correctedLabel       = new QLabel;
    d->maskLabel            = new QLabel;
    d->noSelectionLabel     = new QLabel;
    d->originalLabel        = new QLabel;

    d->correctedLabel->setScaledContents(true);
    d->maskLabel->setScaledContents(true);
    d->originalLabel->setScaledContents(true);

    d->noSelectionLabel->clear();

    d->busyLabel->setText(i18n("<h2>generating preview...</h2>"));
    d->busyLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

    // --------------------------------------------------------

    d->stack = new QStackedWidget;
    d->stack->insertWidget(BusyMode,          d->busyLabel);
    d->stack->insertWidget(LockedMode,        d->noSelectionLabel);
    d->stack->insertWidget(OriginalMode,      d->originalLabel);
    d->stack->insertWidget(CorrectedMode,     d->correctedLabel);
    d->stack->insertWidget(MaskMode,          d->maskLabel);

    // --------------------------------------------------------

    QGraphicsScene* scene = new QGraphicsScene;
    scene->addWidget(d->stack);
    setScene(scene);

    // --------------------------------------------------------

    // floating widgets
    d->modeInfo = new InfoMessageWidget(this);
    d->controller = new ControlWidget(this);

    // --------------------------------------------------------

    connect(this, SIGNAL(settingsChanged()),
            this, SLOT(updateSettings()));

    connect(d->controller, SIGNAL(zoomInClicked()),
            this, SLOT(zoomInClicked()));

    connect(d->controller, SIGNAL(zoomOutClicked()),
            this, SLOT(zoomOutClicked()));

    connect(d->controller, SIGNAL(originalClicked()),
            this, SLOT(originalClicked()));

    connect(d->controller, SIGNAL(correctedClicked()),
            this, SLOT(correctedClicked()));

    connect(d->controller, SIGNAL(maskClicked()),
            this, SLOT(maskClicked()));

    // --------------------------------------------------------

    reset();
}
开发者ID:,项目名称:,代码行数:85,代码来源:

示例12: main

int main(int argc, char **argv)
{
    // Qt requires that we construct the global QApplication before creating any widgets.
    QApplication app(argc, argv);

    // use an ArgumentParser object to manage the program arguments.
    osg::ArgumentParser arguments(&argc,argv);

    // true = run osgViewer in a separate thread than Qt
    // false = interleave osgViewer and Qt in the main thread
    bool useFrameLoopThread = false;
    if (arguments.read("--no-frame-thread")) useFrameLoopThread = false;
    if (arguments.read("--frame-thread")) useFrameLoopThread = true;

    // true = use QWidgetImage
    // false = use QWebViewImage
    bool useWidgetImage = false;
    if (arguments.read("--useWidgetImage")) useWidgetImage = true;

    // true = use QWebView in a QWidgetImage to compare to QWebViewImage
    // false = make an interesting widget
    bool useBrowser = false;
    if (arguments.read("--useBrowser")) useBrowser = true;

    // true = use a QLabel for text
    // false = use a QTextEdit for text
    // (only applies if useWidgetImage == true and useBrowser == false)
    bool useLabel = false;
    if (arguments.read("--useLabel")) useLabel = true;

    // true = make a Qt window with the same content to compare to
    // QWebViewImage/QWidgetImage
    // false = use QWebViewImage/QWidgetImage (depending on useWidgetImage)
    bool sanityCheck = false;
    if (arguments.read("--sanityCheck")) sanityCheck = true;

    // Add n floating windows inside the QGraphicsScene.
    int numFloatingWindows = 0;
    while (arguments.read("--numFloatingWindows", numFloatingWindows));

    // true = Qt widgets will be displayed on a quad inside the 3D scene
    // false = Qt widgets will be an overlay over the scene (like a HUD)
    bool inScene = true;
    if (arguments.read("--fullscreen")) { inScene = false; }


    osg::ref_ptr<osg::Group> root = new osg::Group;

    if (!useWidgetImage)
    {
        //-------------------------------------------------------------------
        // QWebViewImage test
        //-------------------------------------------------------------------
        // Note: When the last few issues with QWidgetImage are fixed,
        // QWebViewImage and this if() {} section can be removed since
        // QWidgetImage can display a QWebView just like QWebViewImage. Use
        // --useWidgetImage --useBrowser to see that in action.

        if (!sanityCheck)
        {
            osg::ref_ptr<osgQt::QWebViewImage> image = new osgQt::QWebViewImage;

            if (arguments.argc()>1) image->navigateTo((arguments[1]));
            else image->navigateTo("http://www.openscenegraph.org/");

            osgWidget::GeometryHints hints(osg::Vec3(0.0f,0.0f,0.0f),
                                           osg::Vec3(1.0f,0.0f,0.0f),
                                           osg::Vec3(0.0f,0.0f,1.0f),
                                           osg::Vec4(1.0f,1.0f,1.0f,1.0f),
                                           osgWidget::GeometryHints::RESIZE_HEIGHT_TO_MAINTAINCE_ASPECT_RATIO);

            osg::ref_ptr<osgWidget::Browser> browser = new osgWidget::Browser;
            browser->assign(image.get(), hints);

            root->addChild(browser.get());
        }
        else
        {
            // Sanity check, do the same thing as QGraphicsViewAdapter but in
            // a separate Qt window.
            QWebPage* webPage = new QWebPage;
            webPage->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
            webPage->settings()->setAttribute(QWebSettings::PluginsEnabled, true);

            QWebView* webView = new QWebView;
            webView->setPage(webPage);

            if (arguments.argc()>1) webView->load(QUrl(arguments[1]));
            else webView->load(QUrl("http://www.openscenegraph.org/"));

            QGraphicsScene* graphicsScene = new QGraphicsScene;
            graphicsScene->addWidget(webView);

            QGraphicsView* graphicsView = new QGraphicsView;
            graphicsView->setScene(graphicsScene);

            QMainWindow* mainWindow = new QMainWindow;
            //mainWindow->setLayout(new QVBoxLayout);
            mainWindow->setCentralWidget(graphicsView);
            mainWindow->setGeometry(50, 50, 1024, 768);
//.........这里部分代码省略.........
开发者ID:yueying,项目名称:osg,代码行数:101,代码来源:osgQtWidgets.cpp

示例13: contextMenuEvent

void OverlayUserGroup::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
	event->accept();

#ifdef Q_OS_MAC
	bool embed = g.ocIntercept != NULL;
	QMenu qm(embed ? NULL : event->widget());
	if (embed) {
		QGraphicsScene *scene = g.ocIntercept->qgv.scene();
		scene->addWidget(&qm);
	}
#else
	QMenu qm(g.ocIntercept ? g.mw : event->widget());
#endif

	QMenu *qmShow = qm.addMenu(OverlayClient::tr("Filter"));

	QAction *qaShowTalking = qmShow->addAction(OverlayClient::tr("Only talking"));
	qaShowTalking->setCheckable(true);
	if (os->osShow == OverlaySettings::Talking)
		qaShowTalking->setChecked(true);

	QAction *qaShowActive = qmShow->addAction(OverlayClient::tr("Talking and recently active"));
	qaShowActive->setCheckable(true);
	if (os->osShow == OverlaySettings::Active)
		qaShowActive->setChecked(true);

	QAction *qaShowHome = qmShow->addAction(OverlayClient::tr("All in current channel"));
	qaShowHome->setCheckable(true);
	if (os->osShow == OverlaySettings::HomeChannel)
		qaShowHome->setChecked(true);

	QAction *qaShowLinked = qmShow->addAction(OverlayClient::tr("All in linked channels"));
	qaShowLinked->setCheckable(true);
	if (os->osShow == OverlaySettings::LinkedChannels)
		qaShowLinked->setChecked(true);

	qmShow->addSeparator();

	QAction *qaShowSelf = qmShow->addAction(OverlayClient::tr("Always show yourself"));
	qaShowSelf->setCheckable(true);
	qaShowSelf->setEnabled(os->osShow == OverlaySettings::Talking || os->osShow == OverlaySettings::Active);
	if (os->bAlwaysSelf)
		qaShowSelf->setChecked(true);

	qmShow->addSeparator();

	QAction *qaConfigureRecentlyActiveTime = qmShow->addAction(OverlayClient::tr("Configure recently active time (%1 seconds)...").arg(os->uiActiveTime));
	qaConfigureRecentlyActiveTime->setEnabled(os->osShow == OverlaySettings::Active);

	QMenu *qmColumns = qm.addMenu(OverlayClient::tr("Columns"));
	QAction *qaColumns[6];
	for (unsigned int i=1;i<=5;++i) {
		qaColumns[i] = qmColumns->addAction(QString::number(i));
		qaColumns[i]->setCheckable(true);
		qaColumns[i]->setChecked(i == os->uiColumns);
	}

	QMenu *qmSort = qm.addMenu(OverlayClient::tr("Sort"));

	QAction *qaSortAlphabetically = qmSort->addAction(OverlayClient::tr("Alphabetically"));
	qaSortAlphabetically->setCheckable(true);
	if (os->osSort == OverlaySettings::Alphabetical)
		qaSortAlphabetically->setChecked(true);

	QAction *qaSortLastStateChange = qmSort->addAction(OverlayClient::tr("Last state change"));
	qaSortLastStateChange->setCheckable(true);
	if (os->osSort == OverlaySettings::LastStateChange)
		qaSortLastStateChange->setChecked(true);

	QAction *qaEdit = qm.addAction(OverlayClient::tr("Edit..."));
	QAction *qaZoom = qm.addAction(OverlayClient::tr("Reset Zoom"));

	QAction *act = qm.exec(event->screenPos());

	if (! act)
		return;

	if (act == qaEdit) {
		if (g.ocIntercept) {
			QMetaObject::invokeMethod(g.ocIntercept, "openEditor", Qt::QueuedConnection);
		} else {
			OverlayEditor oe(qApp->activeModalWidget(), NULL, os);
			connect(&oe, SIGNAL(applySettings()), this, SLOT(updateLayout()));
			oe.exec();
		}
	} else if (act == qaZoom) {
		os->fZoom = 1.0f;
		updateLayout();
	} else if (act == qaShowTalking) {
		os->osShow = OverlaySettings::Talking;
		updateUsers();
	} else if (act == qaShowActive) {
		os->osShow = OverlaySettings::Active;
		updateUsers();
	} else if (act == qaShowHome) {
		os->osShow = OverlaySettings::HomeChannel;
		updateUsers();
	} else if (act == qaShowLinked) {
		os->osShow = OverlaySettings::LinkedChannels;
		updateUsers();
//.........这里部分代码省略.........
开发者ID:Chasophias,项目名称:mumble,代码行数:101,代码来源:OverlayUserGroup.cpp

示例14: view

    return app.exec();
}
//! [0]

//! [1]
QGroupBox *groupBox = new QGroupBox("Contact Details");
QLabel *numberLabel = new QLabel("Telephone number");
QLineEdit *numberEdit = new QLineEdit;

QFormLayout *layout = new QFormLayout;
layout->addRow(numberLabel, numberEdit);
groupBox->setLayout(layout);

QGraphicsScene scene;
QGraphicsProxyWidget *proxy = scene.addWidget(groupBox);

QGraphicsView view(&scene);
view.show();
//! [1]

//! [2]
QGraphicsScene scene;

QLineEdit *edit = new QLineEdit;
QGraphicsProxyWidget *proxy = scene.addWidget(edit);

edit->isVisible();  // returns true
proxy->isVisible(); // also returns true

edit->hide();
开发者ID:3163504123,项目名称:phantomjs,代码行数:30,代码来源:src_gui_graphicsview_qgraphicsproxywidget.cpp

示例15: init

void CWinMainView::init()
{
	qDebug() << "#### CWinMainControler::init" << endl;

	m_tabWidgetCentral = new QTabWidget(); //Pas de parent, setCentralWidget l'attribura à la fenêtre
    QHBoxLayout* layoutGlobal = new QHBoxLayout(); 
    layoutGlobal->setContentsMargins ( 0, 0, 0, 0 );
    layoutGlobal->addWidget(m_tabWidgetCentral);
    
    this->setLayout(layoutGlobal);
	//setCentralWidget(m_tabWidgetCentral);

	//***HISTOGRAMME
	QGraphicsScene* scene = new QGraphicsScene();
#if !defined(RES_640_480)// || defined(MULTI_STREAM)
	scene->setSceneRect(0,0,SCENE_WIDTH, SCENE_HEIGHT);
#endif
	QPen pen(Qt::lightGray, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
	QColor color(Qt::lightGray);
	color.setAlpha(200);
	QBrush brush(color);
	for(int i=0; i<SCENE_HEIGHT-1; i=i+10)
	{
		scene->addLine(0,i,SCENE_WIDTH-15, i, pen);
		/*scene->addText(QString::number(i))->setPos(-10,i-5);	*/		
	}
	pen.setColor(Qt::black);
	scene->addLine(0,SCENE_HEIGHT,SCENE_WIDTH-15, SCENE_HEIGHT, pen);
	m_lblMesureGraph = new QLabel("                            ");
	scene->addWidget(m_lblMesureGraph)->setPos(0,-20);
	m_lblConcentrationMax = new QLabel("1000");
	m_lblConcentrationMax->setObjectName("lblGraphUnit");
	m_lblConcentrationMin = new QLabel("0");
	m_lblConcentrationMin->setObjectName("lblGraphUnit");
	m_lblConcentrationMoy = new QLabel("500");
	m_lblConcentrationMoy->setObjectName("lblGraphUnit");
	QLabel* lblInfo = new QLabel();
	lblInfo->setObjectName("lblGraphInfo");
	
	scene->addWidget(m_lblConcentrationMax)->setPos(SCENE_WIDTH-23,-10);
	scene->addWidget(m_lblConcentrationMoy)->setPos(SCENE_WIDTH-13,(SCENE_HEIGHT/2)-10);
	scene->addWidget(m_lblConcentrationMin)->setPos(SCENE_WIDTH-13,SCENE_HEIGHT-10);
	QGraphicsProxyWidget* proxyLblInfo= new QGraphicsProxyWidget();
	proxyLblInfo->setWidget(lblInfo);
	//proxyLblInfo = scene->addWidget(lblInfo)
	proxyLblInfo->resize(100, 60);
	proxyLblInfo->setPos(SCENE_WIDTH - 140, -20);
	proxyLblInfo->setVisible(false);
	
	int i;
    for(int j=0; j<m_pModel->getNbStream(); ++j)
    {
        QList<CGraphicsRectItem*> list;
	    for(i=0; i<SCENE_WIDTH-20; i=i+10)
	    {
            if(j==0)
            {
		        if(i%4==0 || i==0)
		        {
			        scene->addLine(i,SCENE_HEIGHT+3, i,SCENE_HEIGHT-3, pen);
			        m_listGraphicsRectItem.append(new CGraphicsRectItem(i, SCENE_HEIGHT, 20, 0, proxyLblInfo));//, proxyLblMesure));
			        m_listGraphicsRectItem.last()->setBrush(brush);
			        m_listGraphicsRectItem.last()->setPen(color);
			        scene->addItem(m_listGraphicsRectItem.last());
		        }
		        else
			        scene->addLine(i,SCENE_HEIGHT, i,SCENE_HEIGHT-3, pen);
            }
            if(i%4==0 || i==0)
            {
                list.append(new CGraphicsRectItem(i, SCENE_HEIGHT, 20, 0, proxyLblInfo));//, proxyLblMesure));
                list.last()->setBrush(brush);
                list.last()->setPen(color);
            }
    			
	    }
        m_listDataGraph.append(list);
    }
	scene->addLine(i,SCENE_HEIGHT+3, i,SCENE_HEIGHT-3, pen);
	pen.setColor(Qt::green);
	scene->addItem(proxyLblInfo);
	QGraphicsView* view= new QGraphicsView(scene);
	QHBoxLayout* graphLayout = new QHBoxLayout();
	graphLayout->addWidget(view);
    graphLayout->setContentsMargins ( 0, 0, 0, 0 );
   
	QWidget* widgetGraph = new QWidget();
	widgetGraph->setLayout(graphLayout);
	//FIN HISTGRAMME

	
    
	qDebug() << "#### CWinMainControler::init 0" << endl;
    
	QVBoxLayout* centralLayout = new QVBoxLayout();
	for(int i=0; i<m_pModel->getNbStream(); ++i)
	{

        QList<QLabel*> listLblMesure;
        QList<QLabel*> listLblValMesure;
//.........这里部分代码省略.........
开发者ID:benoitk,项目名称:cristalqt_win,代码行数:101,代码来源:CWinMainView.cpp


注:本文中的QGraphicsScene::addWidget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。