Qt

QTQMdiAreaの紹介



Introduction Qt Qmdiarea



QMdiAreaは通常、メインウィンドウQMainWindowで使用され、複数のサブウィンドウQMdiSubWindowに対応します。

qtcreator 3.0の設計者は、直接ドラッグして使用できるMdiAreaを持っています。



インターフェイスは次のとおりです。画像の灰色のボックスはMdiAreaであり、もう1つの画像は2つのQMdiSubWindowを作成します。



コードは次のように表示されます。

#include 'mainwindow.h' #include 'ui_mainwindow.h' #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this) Connect(ui->actionNew,SIGNAL(triggered()),this,SLOT(creatNewWin()))//actionNew is an action created by the designer } void MainWindow::creatNewWin() { mdiWin1=new QMdiSubWindow mdiWin1->setWindowTitle('undetermined') ui->mdiArea->addSubWindow(mdiWin1) mdiWin1->resize(QSize(200,200)) mdiWin1->show() } MainWindow::~MainWindow() { delete ui } 

______________________________________________________________________________________________

QMdiArea

パブリック関数は次のとおりです。

 QMdiArea(QWidget * parent = 0) ~QMdiArea() QMdiSubWindow * addSubWindow(QWidget * widget, Qt::WindowFlags windowFlags = 0) void removeSubWindow(QWidget * widget) Void setActivationOrder(WindowOrder order)//Set the activation order, the default is to create the activation, the slot function is called, the enumeration value is shown in 1 Void setBackground(const QBrush & background)//Set the background, the default gray void setDocumentMode(bool enabled) Void setOption(AreaOption option, bool on = true)//There is only one option, that is, create a child window, the window does not fill this area, the default is full, the enumeration value is shown in 2 Void setViewMode(ViewMode mode)//Set the viewport mode. There are many small windows in the default area. It can also be in the form of tabBar. The following functions for setting tabs need to be enabled first. Enumeration value see 3 Void setTabPosition(QTabWidget::TabPosition position)//Set the orientation of the tabBar, there are four north and south directions, follow the geography of the north, south, south, west, east, and east. See 4 Void setTabShape(QTabWidget::TabShape shape)//Set the shape of the tab, the default rectangle, or like the Google browser, trapezoidal, enumeration value see 5 Void setTabsClosable(bool closable)//default no, when set to true, a small close button is formed above the tab Void setTabsMovable(bool movable)//Set whether it can be moved, the default is false, when it can be moved, the draggable tab moves on the tabBar. Most browsers now have such a function. QList subWindowList(WindowOrder order = CreationOrder) const QMdiSubWindow * currentSubWindow() const WindowOrder activationOrder() const QBrush background() const bool documentMode() const bool testOption(AreaOption option) const QMdiSubWindow * activeSubWindow() const QTabWidget::TabPosition tabPosition() const QTabWidget::TabShape tabShape() const bool tabsClosable() const bool tabsMovable() const ViewMode viewMode() const 

パブリックスロット

void activateNextSubWindow() void activatePreviousSubWindow() void cascadeSubWindows() void closeActiveSubWindow() void closeAllSubWindows() void setActiveSubWindow(QMdiSubWindow * window) Void tileSubWindows()//Align all child windows in the visible part of the area 

信号

Void subWindowActivated(QMdiSubWindow * window)//When switching the active window  

1、列挙型QMdiArea :: WindowOrder

絶え間ない 説明
QMdiArea :: CreationOrder 0 作成順に
QMdiArea :: StackingOrder 1 積み重ね順
QMdiArea :: ActivationHistoryOrder アクティベーション履歴の前後の注文を押します。

2、列挙型QMdiArea :: AreaOption
フラグQMdiArea :: AreaOptions

絶え間ない 説明
QMdiArea :: DontMaximizeSubWindowOnActivation 0x1 アクティブ化されたときに最大化しないでください。デフォルトは最大化されます

3、QMdiArea :: ViewMode

絶え間ない 説明
QMdiArea :: SubWindowView 0 小さなウィンドウとして表示されます(デフォルト)。
QMdiArea :: TabbedView 1 小さなウィンドウだけでなく、tabBarも

4、列挙型QTabWidget :: TabPosition

絶え間ない 説明
QTabWidget :: North 0 ディスプレイの上
QTabWidget :: South 1
QTabWidget :: West
QTabWidget :: East 3 正しい

5、列挙型QTabWidget :: TabShape

絶え間ない 説明
QTabWidget :: Rounded 0 リテラルは丸いですが、win7は長方形に似ています。デフォルト
QTabWidget ::三角形 1 文字通りの三角形、台形の方が良いと言う

上記のコードで変更された結果は、tileSubWindows()関数の実行後に実行されます。

#include 'mainwindow.h' #include 'ui_mainwindow.h' #include #include #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this) QBrush b=QBrush(QColor(30,30,30),Qt::FDiagPattern) ui->mdiArea->setBackground(b) ui->mdiArea->setViewMode(QMdiArea::TabbedView) ui->mdiArea->setTabPosition(QTabWidget::North) ui->mdiArea->setTabsClosable(true) ui->mdiArea->setTabsMovable(true) ui->mdiArea->setTabShape(QTabWidget::Triangular) ui->mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation) connect(ui->actionNew,SIGNAL(triggered()),this,SLOT(creatNewWin())) } void MainWindow::creatNewWin() { mdiWin1=new QMdiSubWindow mdiWin1->setWindowTitle('undetermined') ui->mdiArea->addSubWindow(mdiWin1) mdiWin1->resize(QSize(200,200)) mdiWin1->show() } MainWindow::~MainWindow() { delete ui } void MainWindow::on_pushButton_clicked() { ui->mdiArea->tileSubWindows() } 

______________________________________________________________________________________________

QMdiSubWindow

関数は比較的単純で、以下にリストされています。

 QMdiSubWindow(QWidget * parent = 0, Qt::WindowFlags flags = 0) ~QMdiSubWindow() void setKeyboardPageStep(int step) void setKeyboardSingleStep(int step) Void setOption(SubWindowOption option, bool on = true)//Untested effect, add, enum value see 1 void setSystemMenu(QMenu * systemMenu).se. Void setWidget(QWidget * widget)//mainly adds its widgets via a function int keyboardPageStep() const int keyboardSingleStep() const QMdiArea * mdiArea() const QMenu * systemMenu() const QWidget * widget() const bool testOption(SubWindowOption option) const bool isShaded() const 

パブリックスロット

ボイド showShaded ()
ボイド showSystemMenu ()

信号

ボイド aboutToActivate ()
ボイド windowStateChanged (Qt :: WindowStates oldState、Qt :: WindowStates newState)



1、列挙型QMdiSubWindow :: SubWindowOption

絶え間ない 説明
QMdiSubWindow :: RubberBandResize 0x4 このオプションを有効にすると、サブウィンドウのアウトラインを表すためにラバーバンドコントロールが使用され、ユーザーはサブウィンドウ自体の代わりにこれのサイズを変更します。その結果、サブウィンドウは、サイズ変更操作が完了するまで元の位置とサイズを維持します。完了すると、サブウィンドウは1つを受け取ります。 QResizeEvent 。デフォルトでは、このオプションは無効になっています。
QMdiSubWindow :: RubberBandMove 0x8 このオプションを有効にすると、サブウィンドウのアウトラインを表すためにラバーバンドコントロールが使用され、ユーザーはサブウィンドウ自体の代わりにこれを移動します。その結果、移動操作が完了するまでサブウィンドウは元の位置に留まります。 QMoveEvent ウィンドウに送信されます。デフォルトでは、このオプションは無効になっています。