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


C++ QPushButton类代码示例

本文整理汇总了C++中QPushButton的典型用法代码示例。如果您正苦于以下问题:C++ QPushButton类的具体用法?C++ QPushButton怎么用?C++ QPushButton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: QDialog

/////////////////////////////////////////////////////////////////////////////////////////////////
// Trade dialog class
/////////////////////////////////////////////////////////////////////////////////////////////////
CasinoDialog::CasinoDialog(const PlayerState* player, QWidget *parent, const char * name)
: QDialog(parent, name, true)
{

	unsigned int money = player->get_money();

	setCaption("Welcome to the Casino.");

//-----------------------------------------------------------------------------------------------
// Set up acceptance and rejection buttons
//-----------------------------------------------------------------------------------------------
		
		QPushButton *ok = new QPushButton ("Place your bet", this);
		ok->setGeometry( 110, 300, 215, 30);
		connect( ok, SIGNAL(clicked()), SLOT(accept()));

		
//-----------------------------------------------------------------------------------------------
// Set up frames for trading players
//-----------------------------------------------------------------------------------------------
		QLabel *avail = new QLabel ( QString("Available Money:  $") + QString::number(money), this);
		avail->setGeometry( 130, 170, 205, 30);
		
		QLabel *betLabel = new QLabel ( "Place Your Bet:", this);
		betLabel->setGeometry( 130, 200, 205, 30);

		_spin = new QSpinBox( (money < 100 ? money : 100) , money, 100, this, "_spin");
		_spin->setGeometry(230, 205, 50, 20);

//-----------------------------------------------------------------------------------------------
// Set up property check boxes for first player
//-----------------------------------------------------------------------------------------------
		QRadioButton *Prop1, *Prop2, *Prop3, *Prop4, *Prop5;

		Prop1 = new QRadioButton( "Any Craps: wins on a throw of 2, 3 or 12 with a payoff of 8:1", this);
		Prop1->setGeometry( 5, 0, 400, 30);

		Prop2 = new QRadioButton( "Any Seven: wins on a throw of 7 with a payoff of 5:1", this);
		Prop2->setGeometry( 5, 25, 400, 30);

		Prop3 = new QRadioButton( "Eleven: wins on a throw of 11 with a payoff of 16:1", this);
		Prop3->setGeometry( 5, 50, 400, 30);

		Prop4 = new QRadioButton( "Ace Duece: wins on a throw of 3 with a payoff of 16:1", this);
		Prop4->setGeometry( 5, 75, 400, 30);

		Prop5 = new QRadioButton( "Aces or Boxcars: wins on a throw of 2 or 12 with a payoff of 30:1", this);
		Prop5->setGeometry( 5, 100, 410, 30);

		_group = new QButtonGroup(this);
		_group->setGeometry(0, 0, 0, 0);
		
		// type = kCCraps, kCSeven, kCEleven, kCDuece, kCAorB
		_group->insert(Prop1,0); // any craps
		_group->insert(Prop2,1); // any seven
		_group->insert(Prop3,2); // eleven
		_group->insert(Prop4,3); // ace duece
		_group->insert(Prop5,4); // aces or boxcars

		setFixedSize(420,335);
}
开发者ID:kylegibson,项目名称:yloponom,代码行数:64,代码来源:CasinoDialog.C

示例2: QGroupBox

GameCFGWidget::GameCFGWidget(QWidget* parent) :
    QGroupBox(parent)
    , mainLayout(this)
    , seedRegexp("\\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\}")
{
    mainLayout.setMargin(0);
    setMinimumHeight(310);
    setMaximumHeight(447);
    setMinimumWidth(470);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    m_master = true;

    // Easy containers for the map/game options in either stacked or tabbed mode

    mapContainerFree = new QWidget();
    mapContainerTabbed = new QWidget();
    optionsContainerFree = new QWidget();
    optionsContainerTabbed = new QWidget();
    tabbed = false;

    // Container for when in tabbed mode

    tabs = new QTabWidget(this);
    tabs->setFixedWidth(470);
    tabs->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
    tabs->addTab(mapContainerTabbed, tr("Map"));
    tabs->addTab(optionsContainerTabbed, tr("Game options"));
    tabs->setObjectName("gameCfgWidgetTabs");
    mainLayout.addWidget(tabs, 1);
    tabs->setVisible(false);

    // Container for when in stacked mode

    StackContainer = new QWidget();
    StackContainer->setObjectName("gameStackContainer");
    mainLayout.addWidget(StackContainer, 1);
    QVBoxLayout * stackLayout = new QVBoxLayout(StackContainer);

    // Map options

    pMapContainer = new HWMapContainer(mapContainerFree);
    stackLayout->addWidget(mapContainerFree, 0, Qt::AlignHCenter);
    pMapContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    pMapContainer->setFixedSize(width() - 14, 278);
    mapContainerFree->setFixedSize(pMapContainer->width(), pMapContainer->height());

    // Horizontal divider

    QFrame * divider = new QFrame();
    divider->setFrameShape(QFrame::HLine);
    divider->setFrameShadow(QFrame::Plain);
    stackLayout->addWidget(divider, 0, Qt::AlignBottom);
    //stackLayout->setRowMinimumHeight(1, 10);

    // Game options

    optionsContainerTabbed->setContentsMargins(0, 0, 0, 0);
    optionsContainerFree->setFixedSize(width() - 14, 140);
    stackLayout->addWidget(optionsContainerFree, 0, Qt::AlignHCenter);

    OptionsInnerContainer = new QWidget(optionsContainerFree);
    m_childWidgets << OptionsInnerContainer;
    OptionsInnerContainer->setFixedSize(optionsContainerFree->width(), optionsContainerFree->height());
    OptionsInnerContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    GBoxOptionsLayout = new QGridLayout(OptionsInnerContainer);

    GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Style"), this), 1, 0);

    Scripts = new QComboBox(this);
    GBoxOptionsLayout->addWidget(Scripts, 1, 1);

    Scripts->setModel(DataManager::instance().gameStyleModel());
    m_curScript = Scripts->currentText();
    connect(Scripts, SIGNAL(currentIndexChanged(int)), this, SLOT(scriptChanged(int)));

    QWidget *SchemeWidget = new QWidget(this);
    GBoxOptionsLayout->addWidget(SchemeWidget, 2, 0, 1, 2);

    QGridLayout *SchemeWidgetLayout = new QGridLayout(SchemeWidget);
    SchemeWidgetLayout->setMargin(0);

    GameSchemes = new QComboBox(SchemeWidget);
    SchemeWidgetLayout->addWidget(GameSchemes, 0, 2);
    connect(GameSchemes, SIGNAL(currentIndexChanged(int)), this, SLOT(schemeChanged(int)));

    SchemeWidgetLayout->addWidget(new QLabel(QLabel::tr("Scheme"), SchemeWidget), 0, 0);

    QPixmap pmEdit(":/res/edit.png");

    QPushButton * goToSchemePage = new QPushButton(SchemeWidget);
    goToSchemePage->setWhatsThis(tr("Edit schemes"));
    goToSchemePage->setIconSize(pmEdit.size());
    goToSchemePage->setIcon(pmEdit);
    goToSchemePage->setMaximumWidth(pmEdit.width() + 6);
    SchemeWidgetLayout->addWidget(goToSchemePage, 0, 3);
    connect(goToSchemePage, SIGNAL(clicked()), this, SLOT(jumpToSchemes()));

    SchemeWidgetLayout->addWidget(new QLabel(QLabel::tr("Weapons"), SchemeWidget), 1, 0);

    WeaponsName = new QComboBox(SchemeWidget);
//.........这里部分代码省略.........
开发者ID:JGunning,项目名称:OpenWorms2,代码行数:101,代码来源:gamecfgwidget.cpp

示例3: QDialog

DiagramDialog::DiagramDialog(Diagram *d, const QString& _DataSet,
                             QWidget *parent, Graph *currentGraph)
                    : QDialog(parent, 0, TRUE, Qt::WDestructiveClose)
{
  Diag = d;
  Graphs.setAutoDelete(true);
  copyDiagramGraphs();   // make a copy of all graphs
  defaultDataSet = _DataSet;
  setCaption(tr("Edit Diagram Properties"));
  changed = false;
  transfer = false;  // have changes be applied ? (used by "Cancel")
  toTake = false;   // double-clicked variable be inserted into graph list ?

  Expr.setPattern("[^\"]+");
  Validator  = new QRegExpValidator(Expr, this);
  ValInteger = new QIntValidator(0, 360, this);
  ValDouble  = new QDoubleValidator(-1e200, 1e200, 6, this);

  QString NameY, NameZ;
  if((Diag->Name == "Rect") || (Diag->Name == "Curve")) {
    NameY = tr("left Axis");
    NameZ = tr("right Axis");
  }
  else if(Diag->Name == "Polar") {
    NameY = tr("y-Axis");
  }
  else if((Diag->Name == "Smith") || (Diag->Name == "ySmith")) {
    NameY = tr("y-Axis");
  }
  else if(Diag->Name == "PS") {
    NameY = tr("smith Axis");
    NameZ = tr("polar Axis");
  }
  else if(Diag->Name == "SP") {
    NameY = tr("polar Axis");
    NameZ = tr("smith Axis");
  }
  else if(Diag->Name == "Rect3D") {
    NameY = tr("y-Axis");
    NameZ = tr("z-Axis");
  }

  
  all = new QVBoxLayout(this); // to provide neccessary size
  QTabWidget *t = new QTabWidget(this);
  all->addWidget(t);

  // ...........................................................
  QVBox *Tab1 = new QVBox(this);
  Tab1->setSpacing(5);

  Label4 = 0;     // different types with same content
  yrLabel = 0;
  yAxisBox = 0;
  Property2 = 0;
  ColorButt = 0;
  hideInvisible = 0;
  rotationX = rotationY = rotationZ = 0;

  QVButtonGroup *InputGroup = new QVButtonGroup(tr("Graph Input"), Tab1);
  GraphInput = new QLineEdit(InputGroup);
  GraphInput->setValidator(Validator);
  connect(GraphInput, SIGNAL(textChanged(const QString&)),
		      SLOT(slotResetToTake(const QString&)));
  QHBox *Box2 = new QHBox(InputGroup);
  Box2->setSpacing(5);

  if(Diag->Name == "Tab") {
    Label1 = new QLabel(tr("Number Notation: "), Box2);
    PropertyBox = new QComboBox(Box2);
    PropertyBox->insertItem(tr("real/imaginary"));
    PropertyBox->insertItem(tr("magnitude/angle (degree)"));
    PropertyBox->insertItem(tr("magnitude/angle (radian)"));
    PropertyBox->setCurrentItem(1);
    connect(PropertyBox, SIGNAL(activated(int)), SLOT(slotSetNumMode(int)));
    Box2->setStretchFactor(new QWidget(Box2), 5); // stretchable placeholder

    Label2 = new QLabel(tr("Precision:"), Box2);
    Property2 = new QLineEdit(Box2);
    Property2->setValidator(ValInteger);
    Property2->setMaxLength(2);
    Property2->setMaximumWidth(25);
    Property2->setText("3");
  }
  else if(Diag->Name != "Truth") {
    Label1 = new QLabel(tr("Color:"),Box2);
    ColorButt = new QPushButton("   ",Box2);
    ColorButt->setMinimumWidth(50);
    ColorButt->setEnabled(false);
    connect(ColorButt, SIGNAL(clicked()), SLOT(slotSetColor()));
    Box2->setStretchFactor(new QWidget(Box2), 5); // stretchable placeholder

    Label3 = new QLabel(tr("Style:"),Box2);
    Label3->setEnabled(false);
    PropertyBox = new QComboBox(Box2);
    PropertyBox->insertItem(tr("solid line"));
    PropertyBox->insertItem(tr("dash line"));
    PropertyBox->insertItem(tr("dot line"));
    if(Diag->Name != "Time") {
      PropertyBox->insertItem(tr("long dash line"));
//.........这里部分代码省略.........
开发者ID:damiansimanuk,项目名称:qucs-qt4,代码行数:101,代码来源:diagramdialog.cpp

示例4: QDialog

HelpAbout::HelpAbout( QWidget* parent, HELPABOUT::TabId tabid )
   : QDialog( parent )
{
   setObjectName( QString::fromUtf8( "HelpAbout" ) );
   title = VkCfg::appName() + " Information";
   setWindowTitle( title );
   
   // top layout
   QVBoxLayout* vbox = new QVBoxLayout( this );
   vbox->setObjectName( QString::fromUtf8( "vbox" ) );
   
   // widget for the top part
   QWidget* hLayoutWidget = new QWidget( this );
   hLayoutWidget->setObjectName( QString::fromUtf8( "hLayoutWidget" ) );
   vbox->addWidget( hLayoutWidget );
   
   // hbox for pic + appname
   QHBoxLayout* hbox = new QHBoxLayout( hLayoutWidget );
   hbox->setObjectName( QString::fromUtf8( "hbox" ) );
   
   // pic
   QLabel* pic = new QLabel( this );
   pic->setPixmap( QPixmap( ":/vk_icons/icons/valkyrie.xpm" ) );
   pic->setFixedSize( pic->sizeHint() );
   hbox->addWidget( pic );
   
   // app info
   QLabel* appName = new QLabel( this );
   QString str = VkCfg::appName() + " v" + VkCfg::appVersion();
   appName->setText( str );
   appName->setFont( QFont( "Times", 18, QFont::Bold ) );
   appName->setFixedSize( appName->sizeHint() );
   hbox->addWidget( appName );
   
   // push the pix+info over to the left
   hbox->addStretch( 10 );
   
   // tabwidget
   tabParent = new QTabWidget( this );
   tabParent->setObjectName( QString::fromUtf8( "tabParent" ) );
   connect( tabParent, SIGNAL( currentChanged( int ) ),
            this,      SLOT( showTab( int ) ) );
   vbox->addWidget( tabParent );
   
   // about_vk tab
   aboutVk = new QTextBrowser( tabParent );
   aboutVk->setObjectName( QString::fromUtf8( "aboutVk" ) );
   QString VkName = VkCfg::appName();
   VkName.replace( 0, 1, VkName[0].toUpper() );
   str = "About " + VkName;
   tabParent->insertTab( HELPABOUT::ABOUT_VK, aboutVk, str );
   
   // license tab
   license = new QTextBrowser( tabParent );
   license->setObjectName( QString::fromUtf8( "license" ) );
   tabParent->insertTab( HELPABOUT::LICENSE, license, "License Agreement" );
   
   // support tab
   support = new QTextBrowser( tabParent );
   support->setObjectName( QString::fromUtf8( "support" ) );
   tabParent->insertTab( HELPABOUT::SUPPORT, support, "Support" );
   
   
   QPushButton* okButt = new QPushButton( "Close", this );
   okButt->setDefault( true );
   okButt->setFixedSize( okButt->sizeHint() );
   connect( okButt, SIGNAL( clicked() ), this, SLOT( accept() ) );
   okButt->setFocus();
   vbox->addWidget( okButt, 0, Qt::AlignRight );
   
   // setup text-browsers
   license->setSource( VkCfg::docDir() + "/about_gpl.html" );
   support->setSource( VkCfg::docDir() + "/support.html" );
   // about_vk source needs version args updating:
   QFile file( VkCfg::docDir() + "/about_vk.html" );
   
   if ( file.open( QIODevice::ReadOnly ) ) {
      QTextStream ts( &file );
      aboutVk->setText( ts.readAll().arg( QT_VERSION_STR ).arg( qVersion() ) );
   }
   
   // start up with the correct page loaded
   tabParent->setCurrentIndex( tabid );
   // and start up at a reasonable size
   resize( 600, 380 );
}
开发者ID:Grindland,项目名称:valkyrie,代码行数:86,代码来源:help_about.cpp

示例5: updateButtons

void NewActionDialog::updateButtons()
{
    QPushButton *okButton = m_ui->buttonBox->button(QDialogButtonBox::Ok);
    okButton->setEnabled(!actionText().isEmpty() && !actionName().isEmpty());
}
开发者ID:Fale,项目名称:qtmoko,代码行数:5,代码来源:newactiondialog.cpp

示例6: MdiSubWindow

/**
 * Constructor.
 */
InstrumentWindow::InstrumentWindow(const QString &wsName, const QString &label,
                                   ApplicationWindow *app, const QString &name,
                                   Qt::WFlags f)
    : MdiSubWindow(app, label, name, f), WorkspaceObserver(),
      m_InstrumentDisplay(NULL), m_simpleDisplay(NULL), m_workspaceName(wsName),
      m_instrumentActor(NULL), m_surfaceType(FULL3D),
      m_savedialog_dir(QString::fromStdString(
                           Mantid::Kernel::ConfigService::Instance().getString(
                               "defaultsave.directory"))),
      mViewChanged(false), m_blocked(false),
      m_instrumentDisplayContextMenuOn(false) {
    setFocusPolicy(Qt::StrongFocus);
    QVBoxLayout *mainLayout = new QVBoxLayout(this);
    QSplitter *controlPanelLayout = new QSplitter(Qt::Horizontal);

    // Add Tab control panel
    mControlsTab = new QTabWidget(this, 0);
    controlPanelLayout->addWidget(mControlsTab);
    controlPanelLayout->setSizePolicy(QSizePolicy::Expanding,
                                      QSizePolicy::Expanding);

    // Create the display widget
    m_InstrumentDisplay = new MantidGLWidget(this);
    m_InstrumentDisplay->installEventFilter(this);
    connect(this, SIGNAL(enableLighting(bool)), m_InstrumentDisplay,
            SLOT(enableLighting(bool)));

    // Create simple display widget
    m_simpleDisplay = new SimpleWidget(this);
    m_simpleDisplay->installEventFilter(this);

    QWidget *aWidget = new QWidget(this);
    m_instrumentDisplayLayout = new QStackedLayout(aWidget);
    m_instrumentDisplayLayout->addWidget(m_InstrumentDisplay);
    m_instrumentDisplayLayout->addWidget(m_simpleDisplay);

    controlPanelLayout->addWidget(aWidget);

    mainLayout->addWidget(controlPanelLayout);

    m_xIntegration = new XIntegrationControl(this);
    mainLayout->addWidget(m_xIntegration);
    connect(m_xIntegration, SIGNAL(changed(double, double)), this,
            SLOT(setIntegrationRange(double, double)));

    // Set the mouse/keyboard operation info and help button
    QHBoxLayout *infoLayout = new QHBoxLayout();
    mInteractionInfo = new QLabel();
    infoLayout->addWidget(mInteractionInfo);
    QPushButton *helpButton = new QPushButton("?");
    helpButton->setMaximumWidth(25);
    connect(helpButton, SIGNAL(clicked()), this, SLOT(helpClicked()));
    infoLayout->addWidget(helpButton);
    infoLayout->setStretchFactor(mInteractionInfo, 1);
    infoLayout->setStretchFactor(helpButton, 0);
    mainLayout->addLayout(infoLayout);

    QSettings settings;
    settings.beginGroup("Mantid/InstrumentWindow");

    // Background colour
    setBackgroundColor(
        settings.value("BackgroundColor", QColor(0, 0, 0, 1.0)).value<QColor>());

    // Create the b=tabs
    createTabs(settings);

    settings.endGroup();

    // Init actions
    m_clearPeakOverlays = new QAction("Clear peaks", this);
    connect(m_clearPeakOverlays, SIGNAL(activated()), this,
            SLOT(clearPeakOverlays()));

    confirmClose(app->confirmCloseInstrWindow);

    setAttribute(Qt::WA_DeleteOnClose);

    // Watch for the deletion of the associated workspace
    observePreDelete();
    observeAfterReplace();
    observeRename();
    observeADSClear();

    connect(app->mantidUI->getAlgMonitor(), SIGNAL(algorithmStarted(void *)),
            this, SLOT(block()));
    connect(app->mantidUI->getAlgMonitor(), SIGNAL(allAlgorithmsStopped()), this,
            SLOT(unblock()));

    const int windowWidth = 800;
    const int tabsSize = windowWidth / 4;
    QList<int> sizes;
    sizes << tabsSize << windowWidth - tabsSize;
    controlPanelLayout->setSizes(sizes);
    controlPanelLayout->setStretchFactor(0, 0);
    controlPanelLayout->setStretchFactor(1, 1);

//.........这里部分代码省略.........
开发者ID:spaceyatom,项目名称:mantid,代码行数:101,代码来源:InstrumentWindow.cpp

示例7: QuasarWindow


//.........这里部分代码省略.........
    lastMarginLabel->setBuddy(_lastMargin);

    QLabel* avgCostLabel = new QLabel(tr("Avg Cost:"), margin);
    _avgCost = new MoneyEdit(margin);
    _avgCost->setFocusPolicy(NoFocus);
    avgCostLabel->setBuddy(_avgCost);

    QLabel* avgProfitLabel = new QLabel(tr("Avg Profit:"), margin);
    _avgProfit = new MoneyEdit(margin);
    avgProfitLabel->setBuddy(_avgProfit);

    QLabel* avgMarginLabel = new QLabel(tr("Avg Margin:"), margin);
    _avgMargin = new PercentEdit(margin);
    avgMarginLabel->setBuddy(_avgMargin);

    marginGrid->setColStretch(2, 1);
    marginGrid->setColStretch(5, 1);
    marginGrid->addColSpacing(2, 10);
    marginGrid->addColSpacing(5, 10);
    marginGrid->addWidget(marginSizeLabel, 1, 0);
    marginGrid->addWidget(_marginSize, 1, 1, AlignLeft | AlignVCenter);
    marginGrid->addWidget(marginPriceLabel, 1, 3);
    marginGrid->addWidget(_marginPrice, 1, 4, AlignLeft | AlignVCenter);
    marginGrid->addWidget(targetLabel, 1, 6);
    marginGrid->addWidget(_targetGM, 1, 7, AlignLeft | AlignVCenter);
    marginGrid->addWidget(repCostLabel, 2, 0);
    marginGrid->addWidget(_repCost, 2, 1, AlignLeft | AlignVCenter);
    marginGrid->addWidget(repProfitLabel, 2, 3);
    marginGrid->addWidget(_repProfit, 2, 4, AlignLeft | AlignVCenter);
    marginGrid->addWidget(repMarginLabel, 2, 6);
    marginGrid->addWidget(_repMargin, 2, 7, AlignLeft | AlignVCenter);
    marginGrid->addWidget(lastCostLabel, 3, 0);
    marginGrid->addWidget(_lastCost, 3, 1, AlignLeft | AlignVCenter);
    marginGrid->addWidget(lastProfitLabel, 3, 3);
    marginGrid->addWidget(_lastProfit, 3, 4, AlignLeft | AlignVCenter);
    marginGrid->addWidget(lastMarginLabel, 3, 6);
    marginGrid->addWidget(_lastMargin, 3, 7, AlignLeft | AlignVCenter);
    marginGrid->addWidget(avgCostLabel, 4, 0);
    marginGrid->addWidget(_avgCost, 4, 1, AlignLeft | AlignVCenter);
    marginGrid->addWidget(avgProfitLabel, 4, 3);
    marginGrid->addWidget(_avgProfit, 4, 4, AlignLeft | AlignVCenter);
    marginGrid->addWidget(avgMarginLabel, 4, 6);
    marginGrid->addWidget(_avgMargin, 4, 7, AlignLeft | AlignVCenter);

    QFrame* box = new QFrame(frame);

    QPushButton* refresh = new QPushButton(tr("&Refresh"), box);
    refresh->setMinimumSize(refresh->sizeHint());
    connect(refresh, SIGNAL(clicked()), SLOT(slotRefresh()));

    QPushButton* save = new QPushButton(tr("&Save"), box);
    save->setMinimumSize(refresh->sizeHint());
    connect(save, SIGNAL(clicked()), SLOT(slotSave()));

    QPushButton* close = new QPushButton(tr("Cl&ose"), box);
    close->setMinimumSize(refresh->sizeHint());
    connect(close, SIGNAL(clicked()), SLOT(slotClose()));

    QGridLayout* boxGrid = new QGridLayout(box);
    boxGrid->setSpacing(6);
    boxGrid->setMargin(6);
    boxGrid->setColStretch(1, 1);
    boxGrid->addWidget(refresh, 0, 0, AlignLeft | AlignVCenter);
    boxGrid->addWidget(save, 0, 1, AlignRight | AlignVCenter);
    boxGrid->addWidget(close, 0, 2, AlignRight | AlignVCenter);

    QGridLayout* grid = new QGridLayout(frame);
    grid->setSpacing(6);
    grid->setMargin(6);
    grid->addMultiCellWidget(top, 0, 0, 0, 1);
    grid->addWidget(price, 1, 0);
    grid->addWidget(cost, 1, 1);
    grid->addMultiCellWidget(margin, 2, 2, 0, 1);
    grid->addMultiCellWidget(box, 3, 3, 0, 1);

    connect(_item, SIGNAL(validData()), SLOT(slotItemChanged()));
    connect(_store, SIGNAL(validData()), SLOT(slotStoreChanged()));
    connect(_priceSize, SIGNAL(activated(int)), SLOT(slotPriceSizeChanged()));
    connect(_price, SIGNAL(validData()), SLOT(slotPriceChanged()));
    connect(_priceBase, SIGNAL(validData()), SLOT(slotPriceBaseChanged()));
    connect(_costSize, SIGNAL(activated(int)), SLOT(slotCostSizeChanged()));
    connect(_cost, SIGNAL(validData()), SLOT(slotCostChanged()));
    connect(_costBase, SIGNAL(validData()), SLOT(slotCostBaseChanged()));
    connect(_marginSize, SIGNAL(activated(int)),SLOT(slotMarginSizeChanged()));
    connect(_marginPrice, SIGNAL(validData()), SLOT(slotMarginPriceChanged()));
    connect(_repCost, SIGNAL(validData()), SLOT(slotRepCostChanged()));
    connect(_repProfit, SIGNAL(validData()), SLOT(slotRepProfitChanged()));
    connect(_repMargin, SIGNAL(validData()), SLOT(slotRepMarginChanged()));
    connect(_lastProfit, SIGNAL(validData()), SLOT(slotLastProfitChanged()));
    connect(_lastMargin, SIGNAL(validData()), SLOT(slotLastMarginChanged()));
    connect(_avgProfit, SIGNAL(validData()), SLOT(slotAvgProfitChanged()));
    connect(_avgMargin, SIGNAL(validData()), SLOT(slotAvgMarginChanged()));

    setStoreId(_quasar->defaultStore());
    _item->setFocus();

    setCentralWidget(frame);
    setCaption(tr("Item Margin"));
    finalize();
}
开发者ID:cwarden,项目名称:quasar,代码行数:101,代码来源:item_margin.cpp

示例8: connect

/*
 * Initialize the GUI interface for the plugin - this is only called once when the plugin is
 * added to the plugin registry in the QGIS application.
 */
void CoordinateCapture::initGui()
{
  mCrs.createFromSrsId( GEOCRS_ID ); // initialize the CRS object

  connect( mQGisIface->mapCanvas()->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( setSourceCrs() ) );
  connect( mQGisIface, SIGNAL( currentThemeChanged( QString ) ), this, SLOT( setCurrentTheme( QString ) ) );

  setSourceCrs(); //set up the source CRS
  mTransform.setDestCRS( mCrs ); // set the CRS in the transform
  mUserCrsDisplayPrecision = ( mCrs.mapUnits() == QGis::Degrees ) ? 5 : 3; // precision depends on CRS units

  // Create the action for tool
  mQActionPointer = new QAction( QIcon(), tr( "Coordinate Capture" ), this );
  // Set the what's this text
  mQActionPointer->setWhatsThis( tr( "Click on the map to view coordinates and capture to clipboard." ) );
  // Connect the action to the run
  connect( mQActionPointer, SIGNAL( triggered() ), this, SLOT( run() ) );
  mQGisIface->addPluginToMenu( tr( "&Coordinate Capture" ), mQActionPointer );

  // create our map tool
  mpMapTool = new CoordinateCaptureMapTool( mQGisIface->mapCanvas() );
  connect( mpMapTool, SIGNAL( mouseMoved( QgsPoint ) ), this, SLOT( mouseMoved( QgsPoint ) ) );
  connect( mpMapTool, SIGNAL( mouseClicked( QgsPoint ) ), this, SLOT( mouseClicked( QgsPoint ) ) );


  // create a little widget with x and y display to put into our dock widget
  QWidget * mypWidget = new QWidget();
  QGridLayout *mypLayout = new QGridLayout( mypWidget );
  mypLayout->setColumnMinimumWidth( 0, 36 );
  mypWidget->setLayout( mypLayout );

  mypUserCrsToolButton = new QToolButton( mypWidget );
  mypUserCrsToolButton->setToolTip( tr( "Click to select the CRS to use for coordinate display" ) );
  connect( mypUserCrsToolButton, SIGNAL( clicked() ), this, SLOT( setCRS() ) );

  mypCRSLabel = new QLabel( mypWidget );
  mypCRSLabel->setGeometry( mypUserCrsToolButton->geometry() );

  mpUserCrsEdit = new QLineEdit( mypWidget );
  mpUserCrsEdit->setReadOnly( true );
  mpUserCrsEdit->setToolTip( tr( "Coordinate in your selected CRS" ) );

  mpCanvasEdit = new QLineEdit( mypWidget );
  mpCanvasEdit->setReadOnly( true );
  mpCanvasEdit->setToolTip( tr( "Coordinate in map canvas coordinate reference system" ) );

  QPushButton * mypCopyButton = new QPushButton( mypWidget );
  mypCopyButton->setText( tr( "Copy to clipboard" ) );
  connect( mypCopyButton, SIGNAL( clicked() ), this, SLOT( copy() ) );

  mpTrackMouseButton = new QToolButton( mypWidget );
  mpTrackMouseButton->setCheckable( true );
  mpTrackMouseButton->setToolTip( tr( "Click to enable mouse tracking. Click the canvas to stop" ) );
  mpTrackMouseButton->setChecked( false );

  // Create the action for tool
  mpCaptureButton = new QPushButton( mypWidget );
  mpCaptureButton->setText( tr( "Start capture" ) );
  mpCaptureButton->setToolTip( tr( "Click to enable coordinate capture" ) );
  mpCaptureButton->setIcon( QIcon( ":/coordinate_capture/coordinate_capture.png" ) );
  mpCaptureButton->setWhatsThis( tr( "Click on the map to view coordinates and capture to clipboard." ) );
  connect( mpCaptureButton, SIGNAL( clicked() ), this, SLOT( run() ) );

  // Set the icons
  setCurrentTheme( "" );

  mypLayout->addWidget( mypUserCrsToolButton, 0, 0 );
  mypLayout->addWidget( mpUserCrsEdit, 0, 1 );
  mypLayout->addWidget( mypCRSLabel, 1, 0 );
  mypLayout->addWidget( mpCanvasEdit, 1, 1 );
  mypLayout->addWidget( mpTrackMouseButton, 2, 0 );
  mypLayout->addWidget( mypCopyButton, 2, 1 );
  mypLayout->addWidget( mpCaptureButton, 3, 1 );


  //create the dock widget
  mpDockWidget = new QDockWidget( tr( "Coordinate Capture" ), mQGisIface->mainWindow() );
  mpDockWidget->setObjectName( "CoordinateCapture" );
  mpDockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
  mQGisIface->addDockWidget( Qt::LeftDockWidgetArea, mpDockWidget );

  // now add our custom widget to the dock - ownership of the widget is passed to the dock
  mpDockWidget->setWidget( mypWidget );

}
开发者ID:,项目名称:,代码行数:89,代码来源:

示例9: return_touched

//
// riceve i caratteri che sono stati digitati:
void widgetKeyBoard::receiptChildKey(QKeyEvent *event, QLineEdit *focusThisControl, bool reset)
{
    static QLineEdit    *nextInput = NULL;

    if (reset == true) { // reinizializza il controllo
        nextInput = this->getNextTextbox(focusThisControl, true);
        return;
}
    if (nextInput == NULL)
        return;
//
    // inizia l'analisi del carattere ricevuto:
    QString newKey = event->text();
    QString tmpReceiptString = nextInput->text();
    int     tmpPos = nextInput->cursorPosition();

    if (NO_SPECIAL_KEY(newKey) == false) {
        if (IS_RETURN(newKey) == true ) { // trattasi di TAB, si sposta alla text successiva
            emit return_touched();
        }
        if (IS_TAB(newKey) == true) { // trattasi di TAB, si sposta alla text successiva
            nextInput = this->setDefaultTextStyle(nextInput);
            nextInput->deselect();
            nextInput = this->getNextTextbox();
            this->controlKeyEcho(nextInput); // status of key echo here
            if (nextInput != NULL) {
                nextInput->setCursorPosition(nextInput->text().length()); // comment this line if you want caret position at current char inserted
                nextInput->setFocus(Qt::TabFocusReason);
            }
        }
        else if (IS_BACK(newKey) == true || IS_BACK_EMB(newKey) == true) { // trattasi di CANCELLARE carattere, elimina il carattere a sinistra
            if (tmpPos-1 >= 0) {
                tmpReceiptString = tmpReceiptString.remove(tmpPos-1, 1);
                nextInput->setText(tmpReceiptString);
                nextInput->setCursorPosition(tmpPos-1);
                nextInput->setSelection(tmpPos-2, 1);
            }
        }
        else if (IS_CANC(newKey) == true) { // trattasi di CANC carattere, elimina il carattere a destra
             tmpReceiptString = tmpReceiptString.remove(tmpPos, 1);
             nextInput->setText(tmpReceiptString);
             nextInput->setCursorPosition(tmpPos);
             nextInput->setSelection(tmpPos-1, 1);
        }
        else if (IS_COPY(newKey) == true || IS_CUT_LEFT(newKey) == true) {
            QPushButton *button = this->findChild<QPushButton *>(KEY_PASTE);

            if (button != NULL) {
                if (nextInput->text().length() != 0) {
                    this->m_clipboard->setText(nextInput->text());
                    if (IS_CUT_LEFT(newKey) == true)
                        nextInput->setText("");
                    button->setEnabled(true);
                }
                else
                    button->setEnabled(false);
            }
        }
        else if (IS_PASTE(newKey) == true)
            nextInput->setText(this->m_clipboard->text());
        else if (IS_ALT(newKey) == true || IS_CTRL_LEFT(newKey) == true)
        {
            ; // non esegue nessuna operazione
        }
    }
    else { // si tratta di un carattere da visualizzare nella casella di testo corrente
        tmpReceiptString = tmpReceiptString.insert(tmpPos, newKey);
        nextInput->setText(tmpReceiptString);
        nextInput->setCursorPosition(tmpPos+1);
        nextInput->setSelection(tmpPos, 1);
    }
}
开发者ID:the-snowwhite,项目名称:HoloSynthED,代码行数:74,代码来源:widgetKeyBoard.cpp

示例10: QComboBox

	void ItemHandlerCombobox::Handle (const QDomElement& item, QWidget *pwidget)
	{
		QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());

		QHBoxLayout *hboxLay = new QHBoxLayout;
		QComboBox *box = new QComboBox (XSD_);

		hboxLay->addWidget (box);

		XSD_->SetTooltip (box, item);
		box->setObjectName (item.attribute ("property"));
		box->setSizeAdjustPolicy (QComboBox::AdjustToContents);
		if (item.hasAttribute ("maxVisibleItems"))
			box->setMaxVisibleItems (item.attribute ("maxVisibleItems").toInt ());

		bool mayHaveDataSource = item.hasAttribute ("mayHaveDataSource") &&
				item.attribute ("mayHaveDataSource").toLower () == "true";
		if (mayHaveDataSource)
		{
			const QString& prop = item.attribute ("property");
			Factory_->RegisterDatasourceSetter (prop,
					[this] (const QString& str, QAbstractItemModel *m, Util::XmlSettingsDialog *xsd)
						{ SetDataSource (str, m, xsd); });
			Propname2Combobox_ [prop] = box;
			Propname2Item_ [prop] = item;
		}

		hboxLay->addStretch ();

		if (item.hasAttribute ("moreThisStuff"))
		{
			QPushButton *moreButt = new QPushButton (tr ("More stuff..."));
			hboxLay->addWidget (moreButt);

			moreButt->setObjectName (item.attribute ("moreThisStuff"));
			connect (moreButt,
					SIGNAL (released ()),
					XSD_,
					SLOT (handleMoreThisStuffRequested ()));
		}

		QDomElement option = item.firstChildElement ("option");
		while (!option.isNull ())
		{
			const auto& images = XSD_->GetImages (option);
			if (!images.isEmpty ())
			{
				const QIcon icon (QPixmap::fromImage (images.at (0)));
				box->addItem (icon,
						XSD_->GetLabel (option),
						option.attribute ("name"));
			}
			else
				box->addItem (XSD_->GetLabel (option),
						option.attribute ("name"));

			auto setColor = [&option, box] (const QString& attr, Qt::ItemDataRole role) -> void
			{
				if (option.hasAttribute (attr))
				{
					const QColor color (option.attribute (attr));
					box->setItemData (box->count () - 1, color, role);
				}
			};
			setColor ("color", Qt::ForegroundRole);
			setColor ("bgcolor", Qt::BackgroundRole);

			option = option.nextSiblingElement ("option");
		}

		connect (box,
				SIGNAL (currentIndexChanged (int)),
				this,
				SLOT (updatePreferences ()));

		QDomElement scriptContainer = item.firstChildElement ("scripts");
		if (!scriptContainer.isNull ())
		{
			Scripter scripter (scriptContainer);

			QStringList fromScript = scripter.GetOptions ();
			Q_FOREACH (const QString& elm, scripter.GetOptions ())
				box->addItem (scripter.HumanReadableOption (elm),
						elm);
		}
开发者ID:,项目名称:,代码行数:85,代码来源:

示例11: QWidget

ThreeAxisDataVisualizator::ThreeAxisDataVisualizator(int duree,int dataFreq,int min, int max, int _type, QWidget *parent):
    QWidget(parent),
    duree_de_visualisation(duree),
    frequency(dataFreq),
    type(_type),
    min(0),
    max(0)
{
    curves = QList<QString>();
    QString typeStr;
    if(type==DataType::acc){
        typeStr = "accelerometre";
    }else  if(type==DataType::gyro){
        typeStr = "gyroscope";
    }else  if(type==DataType::euler){
        typeStr = "euler";
    }else  if(type==DataType::qua){
        typeStr = "quaternion";
    }

    curves.append(typeStr+" x");
    curves.append(typeStr+" y");
    curves.append(typeStr+" z");

    QHBoxLayout * mainLayout = new QHBoxLayout;
    this->setLayout(mainLayout);

    plot = new QwtPlot();
    mainLayout->addWidget(plot,5);

    QWidget * checkBoxGroup = new QWidget(this);
    mainLayout->addWidget(checkBoxGroup,1);

    QVBoxLayout * checkBoxGroupLayout = new QVBoxLayout;
    checkBoxGroup->setLayout(checkBoxGroupLayout);

    QPushButton * resetScaleButton = new QPushButton;
    resetScaleButton->setText("reset y scale");
    setStyleSheet("QPushButton{"
                  "font-family: Futura;"
                  "color:#4C6BCF;"
                  "font-size: 14px;"
                  "border:2px solid ;"
                  "border-color: #4C6BCF;"
                  "border-radius:5px;"
                  "min-height:60;}");

    checkBoxGroupLayout->addWidget(resetScaleButton);

    checkBoxX = new QCheckBox(curves.at(0),checkBoxGroup);
    checkBoxGroupLayout->addWidget(checkBoxX);

    checkBoxY = new QCheckBox(curves.at(1),checkBoxGroup);
    checkBoxGroupLayout->addWidget(checkBoxY);

    checkBoxZ = new QCheckBox(curves.at(2),checkBoxGroup);
    checkBoxGroupLayout->addWidget(checkBoxZ);

    timeSlider = new QSlider(Qt::Horizontal,checkBoxGroup);
    checkBoxGroupLayout->addWidget(timeSlider);

    checkBoxX->setChecked(true);
    checkBoxY->setChecked(true);
    checkBoxZ->setChecked(true);

    QSignalMapper * mapper = new QSignalMapper;
    mapper->setMapping(checkBoxX,0);
    mapper->setMapping(checkBoxY,1);
    mapper->setMapping(checkBoxZ,2);

    connect(checkBoxX,SIGNAL(stateChanged(int)),mapper,SLOT(map()));
    connect(checkBoxY,SIGNAL(stateChanged(int)),mapper,SLOT(map()));
    connect(checkBoxZ,SIGNAL(stateChanged(int)),mapper,SLOT(map()));

    connect(mapper,SIGNAL(mapped(int)),SLOT(handleCheckBox(int)));

    // canvas
    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setLineWidth( 1 );
    canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
    canvas->setBorderRadius( 15 );

    QPalette canvasPalette( Qt::white );
    canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
    canvas->setPalette( canvasPalette );

    plot->setCanvas( canvas );

    QwtPlotScaleItem *it1 = new QwtPlotScaleItem(QwtScaleDraw::BottomScale ,0.0);
    it1->attach(plot);
    plot->enableAxis(QwtPlot::xBottom,false);
    plot->setAxisScale( QwtPlot::xBottom, 0.0, duree_de_visualisation );
    plot->setAxisScale( QwtPlot::yLeft, min, max );

    xCurve = new QwtPlotCurve( curves.at(0));
    xCurve->setRenderHint( QwtPlotItem::RenderAntialiased );
    xCurve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true );
    xCurve->setPen( Qt::red );
    xCurve->attach( plot );

//.........这里部分代码省略.........
开发者ID:jplingrand,项目名称:wimu,代码行数:101,代码来源:ThreeAxisDataVisualizator.cpp

示例12: QWidget

dvrkTeleopQWidget::dvrkTeleopQWidget(const std::string &name, const double &period):
    QWidget(), counter_(0)
{
    is_head_in_ = false;
    is_clutched_ = false;
    is_move_psm_ = false;

    // subscriber
    // NOTE: queue size is set to 1 to make sure data is fresh
    sub_mtm_pose_ = nh_.subscribe("/dvrk_mtm/cartesian_pose_current", 1,
                                    &dvrkTeleopQWidget::master_pose_cb, this);
    sub_psm_pose_ = nh_.subscribe("/dvrk_psm/cartesian_pose_current", 1,
                                   &dvrkTeleopQWidget::slave_pose_cb, this);

    // publisher
    pub_teleop_enable_ = nh_.advertise<std_msgs::Bool>("/dvrk_teleop/enable", 100);
    pub_mtm_control_mode_ = nh_.advertise<std_msgs::Int8>("/dvrk_mtm/control_mode", 100);
    pub_psm_control_mode_ = nh_.advertise<std_msgs::Int8>("/dvrk_psm/control_mode", 100);
    pub_enable_slider_ = nh_.advertise<sensor_msgs::JointState>("/dvrk_mtm/joint_state_publisher/enable_slider", 100);

    // pose display
    mtm_pose_qt_ = new vctQtWidgetFrame4x4DoubleRead;
    psm_pose_qt_ = new vctQtWidgetFrame4x4DoubleRead;

    QVBoxLayout *poseLayout = new QVBoxLayout;
    poseLayout->addWidget(mtm_pose_qt_);
    poseLayout->addWidget(psm_pose_qt_);

    // common console
    QGroupBox *consoleBox = new QGroupBox("Console");
    QPushButton *consoleHomeButton = new QPushButton(tr("Home"));
    QPushButton *consoleManualButton = new QPushButton(tr("Manual"));
    QPushButton *consoleTeleopTestButton = new QPushButton(tr("TeleopTest"));
    consoleTeleopButton = new QPushButton(tr("Teleop"));
    consoleHomeButton->setStyleSheet("font: bold; color: green;");
    consoleManualButton->setStyleSheet("font: bold; color: red;");
    consoleTeleopTestButton->setStyleSheet("font: bold; color: blue;");
    consoleTeleopButton->setStyleSheet("font: bold; color: brown;");
    consoleHomeButton->setCheckable(true);
    consoleManualButton->setCheckable(true);
    consoleTeleopTestButton->setCheckable(true);
    consoleTeleopButton->setCheckable(true);

    QButtonGroup *consoleButtonGroup = new QButtonGroup;
    consoleButtonGroup->setExclusive(true);
    consoleButtonGroup->addButton(consoleHomeButton);
    consoleButtonGroup->addButton(consoleManualButton);
    consoleButtonGroup->addButton(consoleTeleopTestButton);
    consoleButtonGroup->addButton(consoleTeleopButton);

    QHBoxLayout *consoleBoxLayout = new QHBoxLayout;
    consoleBoxLayout->addWidget(consoleHomeButton);
    consoleBoxLayout->addWidget(consoleManualButton);
    consoleBoxLayout->addWidget(consoleTeleopTestButton);
    consoleBoxLayout->addWidget(consoleTeleopButton);
    consoleBoxLayout->addStretch();
    consoleBox->setLayout(consoleBoxLayout);

    // mtm console
    mtmBox = new QGroupBox("MTM");
    QVBoxLayout *mtmBoxLayout = new QVBoxLayout;
    mtmClutchButton = new QPushButton(tr("Clutch"));
    mtmClutchButton->setCheckable(true);
    mtmBoxLayout->addWidget(mtmClutchButton);

    mtmHeadButton = new QPushButton(tr("Head"));
    mtmHeadButton->setCheckable(true);
    mtmBoxLayout->addWidget(mtmHeadButton);

    mtmBoxLayout->addStretch();
    mtmBox->setLayout(mtmBoxLayout);

    // psm console
    psmBox = new QGroupBox("PSM");
    QVBoxLayout *psmBoxLayout = new QVBoxLayout;
    psmMoveButton = new QPushButton(tr("Move Tool"));
    psmMoveButton->setCheckable(true);
    psmBoxLayout->addWidget(psmMoveButton);
    psmBoxLayout->addStretch();
    psmBox->setLayout(psmBoxLayout);

    // rightLayout
    QGridLayout *rightLayout = new QGridLayout;
    rightLayout->addWidget(consoleBox, 0, 0, 1, 2);
    rightLayout->addWidget(mtmBox, 1, 0);
    rightLayout->addWidget(psmBox, 1, 1);

    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addLayout(poseLayout);
    mainLayout->addLayout(rightLayout);

    this->setLayout(mainLayout);
    this->resize(sizeHint());
    this->setWindowTitle("Teleopo GUI");

    // set stylesheet
    std::string filename = ros::package::getPath("dvrk_teleop");
    filename.append("/src/default.css");
    QFile defaultStyleFile(filename.c_str());
    defaultStyleFile.open(QFile::ReadOnly);
//.........这里部分代码省略.........
开发者ID:BerkeleyAutomation,项目名称:dvrk-ros,代码行数:101,代码来源:dvrkTeleopQWidget.cpp

示例13: QWidget

SettingsPageInformation::SettingsPageInformation( QWidget *parent ) :
  QWidget(parent)
{
  setObjectName("SettingsPageInformation");
  setWindowFlags( Qt::Tool );
  setWindowModality( Qt::WindowModal );
  setAttribute(Qt::WA_DeleteOnClose);
  setWindowTitle( tr("Settings - Information") );

  if( parent )
    {
      resize( parent->size() );
    }

  // Layout used by scroll area
  QHBoxLayout *sal = new QHBoxLayout;

  // new widget used as container for the dialog layout.
  QWidget* sw = new QWidget;

  // Scroll area
  QScrollArea* sa = new QScrollArea;
  sa->setWidgetResizable( true );
  sa->setFrameStyle( QFrame::NoFrame );
  sa->setWidget( sw );

#ifdef QSCROLLER
  QScroller::grabGesture( sa->viewport(), QScroller::LeftMouseButtonGesture );
#endif

#ifdef QTSCROLLER
  QtScroller::grabGesture( sa->viewport(), QtScroller::LeftMouseButtonGesture );
#endif

  // Add scroll area to its own layout
  sal->addWidget( sa );

  QHBoxLayout *contentLayout = new QHBoxLayout;
  setLayout(contentLayout);

  // Pass scroll area layout to the content layout.
  contentLayout->addLayout( sal, 10 );

  // The parent of the layout is the scroll widget
  QGridLayout *topLayout = new QGridLayout(sw);

  topLayout->setHorizontalSpacing(20 * Layout::getIntScaledDensity() );
  topLayout->setVerticalSpacing(10 * Layout::getIntScaledDensity() );

  int row=0;

#ifndef ANDROID

  QHBoxLayout *hBox = new QHBoxLayout();

  QPushButton *soundSelection = new QPushButton( tr("Sound Player"), this );
  soundSelection->setToolTip(tr("Select a sound player, use %s if played file is enclosed in command line arguments"));
  hBox->addWidget(soundSelection);

  connect(soundSelection, SIGNAL( clicked()), this, SLOT(slot_openToolDialog()) );

  Qt::InputMethodHints imh;

  soundTool = new QLineEdit( this );
  imh = (soundTool->inputMethodHints() | Qt::ImhNoPredictiveText);
  soundTool->setInputMethodHints(imh);

  connect( soundTool, SIGNAL(returnPressed()),
           MainWindow::mainWindow(), SLOT(slotCloseSip()) );

  hBox->addWidget(soundTool);
  topLayout->addLayout( hBox, row++, 0, 1, 3 );
  topLayout->setRowMinimumHeight( row++, 10 );

#endif

  topLayout->addWidget(new QLabel(tr("Airfield display time:"), this), row, 0);

  spinAirfield = createNumEd( this );
  topLayout->addWidget( spinAirfield, row, 1 );
  row++;
  topLayout->addWidget(new QLabel(tr("Airspace display time:"), this), row, 0);

  spinAirspace = createNumEd( this );
  topLayout->addWidget( spinAirspace, row, 1 );
  row++;
  topLayout->addWidget(new QLabel(tr("Info display time:"), this), row, 0);

  spinInfo = createNumEd( this );
  topLayout->addWidget( spinInfo, row, 1 );
  row++;
  topLayout->addWidget(new QLabel(tr("Waypoint display time:"), this), row, 0);

  spinWaypoint = createNumEd( this );
  topLayout->addWidget( spinWaypoint, row, 1 );
  row++;
  topLayout->addWidget(new QLabel(tr("Warning display time:"), this), row, 0);

  spinWarning = createNumEd( this );
  topLayout->addWidget( spinWarning, row, 1 );
//.........这里部分代码省略.........
开发者ID:Exadios,项目名称:Cumulus,代码行数:101,代码来源:settingspageinformation.cpp

示例14: QWidget

SyntaxEditorWindow::SyntaxEditorWindow(const QSharedPointer<SyntaxList> &syntaxList, const QString &syntaxName,
		const QString &category, const QString &syntaxHint, QWidget *parent) :
		QWidget(parent), syntaxList(syntaxList), syntaxName(syntaxName)
{
	setWindowRole("kadu-syntax-editor");

	setWindowTitle(tr("Kadu syntax editor"));
	setAttribute(Qt::WA_DeleteOnClose);

	QVBoxLayout *layout = new QVBoxLayout(this);

	QSplitter *splitter = new QSplitter(this);
	layout->addWidget(splitter);
	splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	splitter->setChildrenCollapsible(false);

	QWidget *splitterleft = new QWidget(splitter);
	QVBoxLayout *splitterleftlayout = new QVBoxLayout(splitterleft);
	splitterleftlayout->setMargin(0);
	splitterleftlayout->setSpacing(5);

	editor = new QTextEdit(this);
	splitterleftlayout->addWidget(editor);
	editor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	editor->setAcceptRichText(true);
	editor->setPlainText(syntaxList->readSyntax(syntaxName));
	QFont font = this->font();
	font.setFamily("monospace");
	if(font.pixelSize() == -1)
		font.setPointSizeF(font.pointSizeF() - 0.5);
	else
		font.setPixelSize(font.pixelSize() - 2);
	editor->setFont(font);
	editor->setMinimumSize(EDITOR_MINIMUM_SIZE);

	if (!syntaxHint.isEmpty())
	{
		QLabel *editorhint = new QLabel(this);
		splitterleftlayout->addWidget(editorhint);
		editorhint->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
		editorhint->setWordWrap(true);
		editorhint->setText(syntaxHint);
	}

	QWidget *splitterright = new QWidget(splitter);
	QVBoxLayout *splitterrightlayout = new QVBoxLayout(splitterright);
	splitterrightlayout->setMargin(0);
	splitterrightlayout->setSpacing(5);

	previewPanel = new Preview(this);
	splitterrightlayout->addWidget(previewPanel);
	previewPanel->setMinimumHeight(0);
	previewPanel->setMaximumHeight(QWIDGETSIZE_MAX);
	previewPanel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
	previewPanel->setResetBackgroundColor(config_file.readEntry("Look", category + "BgColor"));
	previewPanel->setMinimumSize(PREVIEW_MINIMUM_SIZE);

	QPushButton *previewbutton = new QPushButton(qApp->style()->standardIcon(QStyle::SP_BrowserReload), tr("Refresh Preview"), this);
	splitterrightlayout->addWidget(previewbutton);
	connect(previewbutton, SIGNAL(clicked()), this, SLOT(refreshPreview()));

	QDialogButtonBox *buttonslayout = new QDialogButtonBox(Qt::Horizontal, this);
	layout->addWidget(buttonslayout);
	QPushButton *saveSyntax = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogOkButton), tr("Save"), this);
	QPushButton *saveAsSyntax = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogSaveButton), tr("Save as..."), this);
	QPushButton *cancel = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogCancelButton), tr("Cancel"), this);
	buttonslayout->addButton(saveSyntax, QDialogButtonBox::YesRole);
	buttonslayout->addButton(saveAsSyntax, QDialogButtonBox::ActionRole);
	buttonslayout->addButton(cancel, QDialogButtonBox::RejectRole);

	splitter->setSizes( QList<int>() << splitter->sizeHint().width() << 1 );

	if (syntaxList->isGlobal(syntaxName))
		saveSyntax->setDisabled(true);
	else
		connect(saveSyntax, SIGNAL(clicked()), this, SLOT(save()));
	connect(saveAsSyntax, SIGNAL(clicked()), this, SLOT(saveAs()));
	connect(cancel, SIGNAL(clicked()), this, SLOT(close()));

	loadWindowGeometry(this, "Look", "SyntaxEditorGeometry", 0, 50, 790, 480);
}
开发者ID:partition,项目名称:kadu,代码行数:81,代码来源:syntax-editor-window.cpp

示例15: QWidget

GBAKeyEditor::GBAKeyEditor(InputController* controller, int type, const QString& profile, QWidget* parent)
	: QWidget(parent)
	, m_profileSelect(nullptr)
	, m_type(type)
	, m_profile(profile)
	, m_controller(controller)
{
	setWindowFlags(windowFlags() & ~Qt::WindowFullscreenButtonHint);
	setMinimumSize(300, 300);

	const GBAInputMap* map = controller->map();

	m_keyDU = new KeyEditor(this);
	m_keyDD = new KeyEditor(this);
	m_keyDL = new KeyEditor(this);
	m_keyDR = new KeyEditor(this);
	m_keySelect = new KeyEditor(this);
	m_keyStart = new KeyEditor(this);
	m_keyA = new KeyEditor(this);
	m_keyB = new KeyEditor(this);
	m_keyL = new KeyEditor(this);
	m_keyR = new KeyEditor(this);

	refresh();

#ifdef BUILD_SDL
	lookupAxes(map);

	if (type == SDL_BINDING_BUTTON) {
		m_profileSelect = new QComboBox(this);
		m_profileSelect->addItems(controller->connectedGamepads(type));
		int activeGamepad = controller->gamepad(type);
		if (activeGamepad > 0) {
			m_profileSelect->setCurrentIndex(activeGamepad);
		}

		connect(m_profileSelect, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this] (int i) {
			m_controller->setGamepad(m_type, i);
			m_profile = m_profileSelect->currentText();
			m_controller->loadProfile(m_type, m_profile);
			refresh();
		});
	}
#endif

	connect(m_keyDU, SIGNAL(valueChanged(int)), this, SLOT(setNext()));
	connect(m_keyDD, SIGNAL(valueChanged(int)), this, SLOT(setNext()));
	connect(m_keyDL, SIGNAL(valueChanged(int)), this, SLOT(setNext()));
	connect(m_keyDR, SIGNAL(valueChanged(int)), this, SLOT(setNext()));
	connect(m_keySelect, SIGNAL(valueChanged(int)), this, SLOT(setNext()));
	connect(m_keyStart, SIGNAL(valueChanged(int)), this, SLOT(setNext()));
	connect(m_keyA, SIGNAL(valueChanged(int)), this, SLOT(setNext()));
	connect(m_keyB, SIGNAL(valueChanged(int)), this, SLOT(setNext()));
	connect(m_keyL, SIGNAL(valueChanged(int)), this, SLOT(setNext()));
	connect(m_keyR, SIGNAL(valueChanged(int)), this, SLOT(setNext()));

	connect(m_keyDU, SIGNAL(axisChanged(int, int)), this, SLOT(setNext()));
	connect(m_keyDD, SIGNAL(axisChanged(int, int)), this, SLOT(setNext()));
	connect(m_keyDL, SIGNAL(axisChanged(int, int)), this, SLOT(setNext()));
	connect(m_keyDR, SIGNAL(axisChanged(int, int)), this, SLOT(setNext()));
	connect(m_keySelect, SIGNAL(axisChanged(int, int)), this, SLOT(setNext()));
	connect(m_keyStart, SIGNAL(axisChanged(int, int)), this, SLOT(setNext()));
	connect(m_keyA, SIGNAL(axisChanged(int, int)), this, SLOT(setNext()));
	connect(m_keyB, SIGNAL(axisChanged(int, int)), this, SLOT(setNext()));
	connect(m_keyL, SIGNAL(axisChanged(int, int)), this, SLOT(setNext()));
	connect(m_keyR, SIGNAL(axisChanged(int, int)), this, SLOT(setNext()));

	m_buttons = new QWidget(this);
	QVBoxLayout* layout = new QVBoxLayout;
	m_buttons->setLayout(layout);

	QPushButton* setAll = new QPushButton(tr("Set all"));
	connect(setAll, SIGNAL(pressed()), this, SLOT(setAll()));
	layout->addWidget(setAll);

	QPushButton* save = new QPushButton(tr("Save"));
	connect(save, SIGNAL(pressed()), this, SLOT(save()));
	layout->addWidget(save);
	layout->setSpacing(6);

	m_keyOrder = QList<KeyEditor*>{
		m_keyDU,
		m_keyDR,
		m_keyDD,
		m_keyDL,
		m_keyA,
		m_keyB,
		m_keySelect,
		m_keyStart,
		m_keyL,
		m_keyR
	};

	m_currentKey = m_keyOrder.end();

	m_background.load(":/res/keymap.qpic");

	setAll->setFocus();
}
开发者ID:hokata,项目名称:mgba,代码行数:99,代码来源:GBAKeyEditor.cpp


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