PDA

View Full Version : widget Position



johan07
14th November 2015, 15:23
Hi,
i wanted to create QCombobox



formcharacter=new QWidget(this);
formcharacter->show();

liste = new QComboBox(formcharacter);
connect(myapp,SIGNAL(BoneAdede( QString )), this, SLOT( BoneAdede( QString)));


but my QComboBox be in the top of the mainwindows
how i made to get it in good position for ewample in the left of widget i can resize it and move it with mouse ?

anda_skoa
14th November 2015, 15:37
http://doc.qt.io/qt-5/layout.html

Cheers,
_

johan07
14th November 2015, 16:19
OK, i see an example , i wanted to make as it :

formcharacter=new QWidget(this);
liste = new QComboBox();
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(liste);
formcharacter->setLayout(layout);
formcharacter->show();


but nothing changed

ChrisW67
14th November 2015, 20:44
Sure something changed. Your combo box is no longer just sitting on top of the formcharacter widget, it is layed out inside the widget and will resize with it.

Perhaps you can better explain what you are expecting to happen.

johan07
15th November 2015, 09:33
Hi,
Ok i will try to explain
i wanted to see my scene in the central widget, then in the left of my main window i see 3 button "annimer,arreter and reply"
i have too an tool bar when i choose "personnag" i must see widget where there is the combox
this picture
11517
that's what i get from my code


MainWindow::MainWindow()
{
mQOgreWidget = new QOgreWidget(this);
setCentralWidget(mQOgreWidget);
createMenu();
}

setCentralWidget(mQOgreWidget); is to set the widget where is my scene in the central of the main window, and we can see in the picture that work
createMenu() is the function where is my toolbar and the other widget
the code of createMenu()


void MainWindow::createMenu()
{
actionOuvrir = new QAction(this);
actionOuvrir->setObjectName(QString::fromUtf8("actionOuvrir"));
actionSauvegarder = new QAction(this);
actionSauvegarder->setObjectName(QString::fromUtf8("actionSauvegarder"));
actionCylindre = new QAction(this);
actionCylindre->setObjectName(QString::fromUtf8("actionCylindre"));
actionCube = new QAction(this);
actionCube->setObjectName(QString::fromUtf8("actionCube"));
actionSphere = new QAction(this);
actionSphere->setObjectName(QString::fromUtf8("actionSphere"));
/**************************/
actionPersonnage = new QAction(this);
actionPersonnage->setObjectName(QString::fromUtf8("actionPersonnage"));
/**************************/
actionFichier_C3D = new QAction(this);
actionFichier_C3D->setObjectName(QString::fromUtf8("actionFichier_C3D"));
/**************************/
actionFichier_BVH = new QAction(this);
actionFichier_BVH->setObjectName(QString::fromUtf8("actionFichier_BVH"));
/****************Camera**********/
actionAjouter = new QAction(this);
actionAjouter->setObjectName(QString::fromUtf8("actionAjouter"));
actionModifier = new QAction(this);
actionModifier->setObjectName(QString::fromUtf8("actionModifier"));
actionSupprimer = new QAction(this);
actionSupprimer->setObjectName(QString::fromUtf8("actionSupprimer"));
/**************Tag*************************/
actionAjouter_2 = new QAction(this);
actionAjouter_2->setObjectName(QString::fromUtf8("actionAjouter_2"));
actionModifier_2 = new QAction(this);
actionModifier_2->setObjectName(QString::fromUtf8("actionModifier_2"));
actionSupprimer_2 = new QAction(this);
actionSupprimer_2->setObjectName(QString::fromUtf8("actionSupprimer_2"));
/**************contraintes****************/
actionContraintes = new QAction(this);
actionContraintes->setObjectName(QString::fromUtf8("actionContraintes"));
/********************************************/
actionSauvegarder_2 = new QAction(this);
actionSauvegarder_2->setObjectName(QString::fromUtf8("actionSauvegarder_2"));
actionQuitter = new QAction(this);
actionQuitter->setObjectName(QString::fromUtf8("actionQuitter"));
centralwidget = new QWidget(this);
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
mdiArea = new QMdiArea(centralwidget);
mdiArea->setObjectName(QString::fromUtf8("mdiArea"));
mdiArea->setGeometry(QRect(209, -1, 581, 421));
subwindow = new QWidget();
subwindow->setObjectName(QString::fromUtf8("subwindow"));
mdiArea->addSubWindow(subwindow);
dockWidget_5 = new QDockWidget(this);
dockWidget_5->setObjectName(QString::fromUtf8("dockWidget_5"));
dockWidgetContents_8 = new QWidget();
dockWidgetContents_8->setObjectName(QString::fromUtf8("dockWidgetContents_8"));
/*********listviex***********************/
listView = new QListView(dockWidgetContents_8);
listView->setObjectName(QString::fromUtf8("listView"));
listView->setGeometry(QRect(0, 0, 281, 291));
listView->setModel( model );
connect(mQOgreWidget,SIGNAL( itemAded( QStandardItem *,int )), this, SLOT( itemAded( QStandardItem *,int ) ));
/**********************************************/
scrollArea = new QScrollArea(dockWidgetContents_8);
scrollArea->setObjectName(QString::fromUtf8("scrollArea"));
scrollArea->setGeometry(QRect(0, 290, 281, 251));
scrollArea->setWidgetResizable(true);
scrollAreaWidgetContents = new QWidget();
scrollAreaWidgetContents->setObjectName(QString::fromUtf8("scrollAreaWidgetContents"));
scrollAreaWidgetContents->setGeometry(QRect(0, 0, 279, 249));
scrollArea->setWidget(scrollAreaWidgetContents);
dockWidget_5->setWidget(dockWidgetContents_8);
addDockWidget(static_cast<Qt::DockWidgetArea>(2), dockWidget_5);
menuBar = new QMenuBar(this);
menuBar->setObjectName(QString::fromUtf8("menuBar"));
menuBar->setGeometry(QRect(0, 0, 1060, 21));
menuLoad = new QMenu(menuBar);
menuLoad->setObjectName(QString::fromUtf8("menuLoad"));
menuAjouter = new QMenu(menuBar);
menuAjouter->setObjectName(QString::fromUtf8("menuAjouter"));
menuObjet = new QMenu(menuAjouter);
menuObjet->setObjectName(QString::fromUtf8("menuObjet"));
menuImport = new QMenu(menuBar);
menuImport->setObjectName(QString::fromUtf8("menuImport"));
menuCam_ra = new QMenu(menuBar);
menuCam_ra->setObjectName(QString::fromUtf8("menuCam_ra"));
menuTags = new QMenu(menuBar);
menuTags->setObjectName(QString::fromUtf8("menuTags"));
menuContraintes= new QMenu(menuBar);
menuContraintes->setObjectName(QString::fromUtf8("menuContraintes"));
setMenuBar(menuBar);
statusbar = new QStatusBar(this);
statusbar->setObjectName(QString::fromUtf8("statusbar"));
setStatusBar(statusbar);
menuBar->addAction(menuLoad->menuAction());
menuBar->addAction(menuAjouter->menuAction());
menuBar->addAction(menuImport->menuAction());
menuBar->addAction(menuCam_ra->menuAction());
menuBar->addAction(menuTags->menuAction());
menuLoad->addSeparator();
menuLoad->addAction(actionOuvrir);
menuLoad->addAction(actionSauvegarder);
menuLoad->addAction(actionSauvegarder_2);
menuLoad->addAction(actionQuitter);
menuAjouter->addAction(menuObjet->menuAction());
menuAjouter->addAction(actionPersonnage);
menuObjet->addAction(actionCylindre);
menuObjet->addAction(actionCube);
menuObjet->addAction(actionSphere);
menuImport->addAction(actionFichier_C3D);
menuImport->addAction(actionFichier_BVH);
menuCam_ra->addAction(actionAjouter);
menuCam_ra->addAction(actionModifier);
menuCam_ra->addAction(actionSupprimer);
menuTags->addAction(actionAjouter_2);
menuTags->addAction(actionModifier_2);
menuTags->addAction(actionSupprimer_2);
menuContraintes->addAction(actionContraintes);

widget = new QWidget(this);
widget->setObjectName(QString::fromUtf8("page_15"));
widget->setGeometry(QRect(50, 500, 211, 250));
anim = new QToolButton(widget);
arret = new QToolButton(widget);
Replay = new QToolButton(widget);
anim->setGeometry(QRect(10, 30, 131, 51))/*setGeometry(QRect(0, 10, 71, 31))*/;
anim->setText(QApplication::translate("MainWindow", "Animer", 0, QApplication::UnicodeUTF8));
anim->setCheckable(true);
arret->setGeometry(QRect(10, 100, 131, 51))/*setGeometry(QRect(0, 10, 71, 31))*/;
arret->setText(QApplication::translate("MainWindow", "Arreter", 0, QApplication::UnicodeUTF8));
arret->setCheckable(true);
connect( arret, SIGNAL(clicked()), this, SLOT( stop()));
Replay->setGeometry(QRect(10, 200, 131, 51))/*setGeometry(QRect(0, 10, 71, 31))*/;
Replay->setText(QApplication::translate("MainWindow", "replay", 0, QApplication::UnicodeUTF8));
Replay->setCheckable(true);
/*************/
formcharacter=new QWidget(this);
liste = new QComboBox();
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(liste);
formcharacter->setLayout(layout);
formcharacter->show();
}

But as you can see in the picture the buttons are not in the left of the window, the QComboBox is in the top of the windows!!
can somone help me to fix those problems ?

ChrisW67
15th November 2015, 19:44
If you want the combobox to be a child of the widget you create at line 119 then you should create it with that widget as its parent (as you do for the others at 122-124).

You should consider using a layout in the widget from line 119 rather than the absolute positioning you are doing now.

johan07
15th November 2015, 19:53
If you want the combobox to be a child of the widget you create at line 119 then you should create it with that widget as its parent (as you do for the others at 122-124).

You should consider using a layout in the widget from line 119 rather than the absolute positioning you are doing now.
what you mean?
but even the widget and the lines at 122-124 are not well positionned , they must be in the left of the minwidow, not the left of the central widget