MochiuWiki : SUSE, EC, PCB
案内
メインページ
最近の更新
おまかせ表示
MediaWiki についてのヘルプ
ツール
リンク元
関連ページの更新状況
特別ページ
ページ情報
We ask for
Donations
検索
個人用ツール
ログイン
Toggle dark mode
名前空間
ページ
議論
表示
閲覧
ソースを閲覧
履歴を表示
Qtのコントロール - コンボボックスのソースを表示
提供: MochiuWiki : SUSE, EC, PCB
←
Qtのコントロール - コンボボックス
あなたには「このページの編集」を行う権限がありません。理由は以下の通りです:
この操作は、次のグループのいずれかに属する利用者のみが実行できます:
管理者
、new-group。
このページのソースの閲覧やコピーができます。
== 概要 == <br><br> == サンプルコード == 以下に、QCombBoxを使用したサンプルコードを示す。<br> <br> mainwindow.uiファイルにおいて、ComboBoxコントロールとPushButtonコントロールを配置する。<br> PushButtonコントロールのシグナルは<code>clicked()</code>、スロットは<code>OnBtnClicked()</code>を選択する。<br> <br> ComboBoxコントロールの1つ目のアイテムを選択した場合、メッセージボックスに0を表示する。<br> また、2つ目のアイテムの場合は1、3つ目のアイテムの場合は2を表示する。<br> <syntaxhighlight lang="c++"> // mainwindow.cpp #include "mainwindow.h" #include "ui_mainwindow.h" #include <QMessageBox> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->comboBox->addItem("Fox1"); ui->comboBox->addItem("Fox2"); ui->comboBox->addItem("Fox3"); } MainWindow::~MainWindow() { delete ui; } void MainWindow::OnBtnClicked() { // This property holds the index of the current item in the combobox. QString strIndex = QString::number(ui->comboBox->currentIndex()); QMessageBox::information(this, "title", strIndex); } </syntaxhighlight> <br> 以下の例では、ComboBoxコントロールにおいて、指定した要素にアイテムを挿入している。<br> <syntaxhighlight lang="c++"> // mainwindow.cpp #include "mainwindow.h" #include "ui_mainwindow.h" #include <QMessageBox> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->comboBox->addItem("Fox1"); ui->comboBox->addItem("Fox2"); ui->comboBox->addItem("Fox3"); ui->comboBox->insertItem(1, "homing missile"); } MainWindow::~MainWindow() { delete ui; } void MainWindow::OnBtnClicked() { // This property holds the index of the current item in the combobox QString strIndex = QString::number(ui->comboBox->currentIndex()); QMessageBox::information(this, "title", strIndex); } </syntaxhighlight> <br><br> __FORCETOC__ [[カテゴリ:Qt]]
Qtのコントロール - コンボボックス
に戻る。
案内
メインページ
最近の更新
おまかせ表示
MediaWiki についてのヘルプ
ツール
リンク元
関連ページの更新状況
特別ページ
ページ情報
We ask for
Donations
Collapse