Results 1 to 7 of 7

Thread: widget Position

  1. #1
    Join Date
    Dec 2012
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default widget Position

    Hi,
    i wanted to create QCombobox
    Qt Code:
    1. formcharacter=new QWidget(this);
    2. formcharacter->show();
    3.  
    4. liste = new QComboBox(formcharacter);
    5. connect(myapp,SIGNAL(BoneAdede( QString )), this, SLOT( BoneAdede( QString)));
    To copy to clipboard, switch view to plain text mode 
    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 ?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: widget Position


  3. #3
    Join Date
    Dec 2012
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: widget Position

    OK, i see an example , i wanted to make as it :
    Qt Code:
    1. formcharacter=new QWidget(this);
    2. liste = new QComboBox();
    3. QHBoxLayout *layout = new QHBoxLayout;
    4. layout->addWidget(liste);
    5. formcharacter->setLayout(layout);
    6. formcharacter->show();
    To copy to clipboard, switch view to plain text mode 

    but nothing changed

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: widget Position

    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.

  5. #5
    Join Date
    Dec 2012
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: widget Position

    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
    qt interface.jpg
    that's what i get from my code
    Qt Code:
    1. MainWindow::MainWindow()
    2. {
    3. mQOgreWidget = new QOgreWidget(this);
    4. setCentralWidget(mQOgreWidget);
    5. createMenu();
    6. }
    To copy to clipboard, switch view to plain text mode 
    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()
    Qt Code:
    1. void MainWindow::createMenu()
    2. {
    3. actionOuvrir = new QAction(this);
    4. actionOuvrir->setObjectName(QString::fromUtf8("actionOuvrir"));
    5. actionSauvegarder = new QAction(this);
    6. actionSauvegarder->setObjectName(QString::fromUtf8("actionSauvegarder"));
    7. actionCylindre = new QAction(this);
    8. actionCylindre->setObjectName(QString::fromUtf8("actionCylindre"));
    9. actionCube = new QAction(this);
    10. actionCube->setObjectName(QString::fromUtf8("actionCube"));
    11. actionSphere = new QAction(this);
    12. actionSphere->setObjectName(QString::fromUtf8("actionSphere"));
    13. /**************************/
    14. actionPersonnage = new QAction(this);
    15. actionPersonnage->setObjectName(QString::fromUtf8("actionPersonnage"));
    16. /**************************/
    17. actionFichier_C3D = new QAction(this);
    18. actionFichier_C3D->setObjectName(QString::fromUtf8("actionFichier_C3D"));
    19. /**************************/
    20. actionFichier_BVH = new QAction(this);
    21. actionFichier_BVH->setObjectName(QString::fromUtf8("actionFichier_BVH"));
    22. /****************Camera**********/
    23. actionAjouter = new QAction(this);
    24. actionAjouter->setObjectName(QString::fromUtf8("actionAjouter"));
    25. actionModifier = new QAction(this);
    26. actionModifier->setObjectName(QString::fromUtf8("actionModifier"));
    27. actionSupprimer = new QAction(this);
    28. actionSupprimer->setObjectName(QString::fromUtf8("actionSupprimer"));
    29. /**************Tag*************************/
    30. actionAjouter_2 = new QAction(this);
    31. actionAjouter_2->setObjectName(QString::fromUtf8("actionAjouter_2"));
    32. actionModifier_2 = new QAction(this);
    33. actionModifier_2->setObjectName(QString::fromUtf8("actionModifier_2"));
    34. actionSupprimer_2 = new QAction(this);
    35. actionSupprimer_2->setObjectName(QString::fromUtf8("actionSupprimer_2"));
    36. /**************contraintes****************/
    37. actionContraintes = new QAction(this);
    38. actionContraintes->setObjectName(QString::fromUtf8("actionContraintes"));
    39. /********************************************/
    40. actionSauvegarder_2 = new QAction(this);
    41. actionSauvegarder_2->setObjectName(QString::fromUtf8("actionSauvegarder_2"));
    42. actionQuitter = new QAction(this);
    43. actionQuitter->setObjectName(QString::fromUtf8("actionQuitter"));
    44. centralwidget = new QWidget(this);
    45. centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
    46. mdiArea = new QMdiArea(centralwidget);
    47. mdiArea->setObjectName(QString::fromUtf8("mdiArea"));
    48. mdiArea->setGeometry(QRect(209, -1, 581, 421));
    49. subwindow = new QWidget();
    50. subwindow->setObjectName(QString::fromUtf8("subwindow"));
    51. mdiArea->addSubWindow(subwindow);
    52. dockWidget_5 = new QDockWidget(this);
    53. dockWidget_5->setObjectName(QString::fromUtf8("dockWidget_5"));
    54. dockWidgetContents_8 = new QWidget();
    55. dockWidgetContents_8->setObjectName(QString::fromUtf8("dockWidgetContents_8"));
    56. /*********listviex***********************/
    57. listView = new QListView(dockWidgetContents_8);
    58. listView->setObjectName(QString::fromUtf8("listView"));
    59. listView->setGeometry(QRect(0, 0, 281, 291));
    60. listView->setModel( model );
    61. connect(mQOgreWidget,SIGNAL( itemAded( QStandardItem *,int )), this, SLOT( itemAded( QStandardItem *,int ) ));
    62. /**********************************************/
    63. scrollArea = new QScrollArea(dockWidgetContents_8);
    64. scrollArea->setObjectName(QString::fromUtf8("scrollArea"));
    65. scrollArea->setGeometry(QRect(0, 290, 281, 251));
    66. scrollArea->setWidgetResizable(true);
    67. scrollAreaWidgetContents = new QWidget();
    68. scrollAreaWidgetContents->setObjectName(QString::fromUtf8("scrollAreaWidgetContents"));
    69. scrollAreaWidgetContents->setGeometry(QRect(0, 0, 279, 249));
    70. scrollArea->setWidget(scrollAreaWidgetContents);
    71. dockWidget_5->setWidget(dockWidgetContents_8);
    72. addDockWidget(static_cast<Qt::DockWidgetArea>(2), dockWidget_5);
    73. menuBar = new QMenuBar(this);
    74. menuBar->setObjectName(QString::fromUtf8("menuBar"));
    75. menuBar->setGeometry(QRect(0, 0, 1060, 21));
    76. menuLoad = new QMenu(menuBar);
    77. menuLoad->setObjectName(QString::fromUtf8("menuLoad"));
    78. menuAjouter = new QMenu(menuBar);
    79. menuAjouter->setObjectName(QString::fromUtf8("menuAjouter"));
    80. menuObjet = new QMenu(menuAjouter);
    81. menuObjet->setObjectName(QString::fromUtf8("menuObjet"));
    82. menuImport = new QMenu(menuBar);
    83. menuImport->setObjectName(QString::fromUtf8("menuImport"));
    84. menuCam_ra = new QMenu(menuBar);
    85. menuCam_ra->setObjectName(QString::fromUtf8("menuCam_ra"));
    86. menuTags = new QMenu(menuBar);
    87. menuTags->setObjectName(QString::fromUtf8("menuTags"));
    88. menuContraintes= new QMenu(menuBar);
    89. menuContraintes->setObjectName(QString::fromUtf8("menuContraintes"));
    90. setMenuBar(menuBar);
    91. statusbar = new QStatusBar(this);
    92. statusbar->setObjectName(QString::fromUtf8("statusbar"));
    93. setStatusBar(statusbar);
    94. menuBar->addAction(menuLoad->menuAction());
    95. menuBar->addAction(menuAjouter->menuAction());
    96. menuBar->addAction(menuImport->menuAction());
    97. menuBar->addAction(menuCam_ra->menuAction());
    98. menuBar->addAction(menuTags->menuAction());
    99. menuLoad->addSeparator();
    100. menuLoad->addAction(actionOuvrir);
    101. menuLoad->addAction(actionSauvegarder);
    102. menuLoad->addAction(actionSauvegarder_2);
    103. menuLoad->addAction(actionQuitter);
    104. menuAjouter->addAction(menuObjet->menuAction());
    105. menuAjouter->addAction(actionPersonnage);
    106. menuObjet->addAction(actionCylindre);
    107. menuObjet->addAction(actionCube);
    108. menuObjet->addAction(actionSphere);
    109. menuImport->addAction(actionFichier_C3D);
    110. menuImport->addAction(actionFichier_BVH);
    111. menuCam_ra->addAction(actionAjouter);
    112. menuCam_ra->addAction(actionModifier);
    113. menuCam_ra->addAction(actionSupprimer);
    114. menuTags->addAction(actionAjouter_2);
    115. menuTags->addAction(actionModifier_2);
    116. menuTags->addAction(actionSupprimer_2);
    117. menuContraintes->addAction(actionContraintes);
    118.  
    119. widget = new QWidget(this);
    120. widget->setObjectName(QString::fromUtf8("page_15"));
    121. widget->setGeometry(QRect(50, 500, 211, 250));
    122. anim = new QToolButton(widget);
    123. arret = new QToolButton(widget);
    124. Replay = new QToolButton(widget);
    125. anim->setGeometry(QRect(10, 30, 131, 51))/*setGeometry(QRect(0, 10, 71, 31))*/;
    126. anim->setText(QApplication::translate("MainWindow", "Animer", 0, QApplication::UnicodeUTF8));
    127. anim->setCheckable(true);
    128. arret->setGeometry(QRect(10, 100, 131, 51))/*setGeometry(QRect(0, 10, 71, 31))*/;
    129. arret->setText(QApplication::translate("MainWindow", "Arreter", 0, QApplication::UnicodeUTF8));
    130. arret->setCheckable(true);
    131. connect( arret, SIGNAL(clicked()), this, SLOT( stop()));
    132. Replay->setGeometry(QRect(10, 200, 131, 51))/*setGeometry(QRect(0, 10, 71, 31))*/;
    133. Replay->setText(QApplication::translate("MainWindow", "replay", 0, QApplication::UnicodeUTF8));
    134. Replay->setCheckable(true);
    135. /*************/
    136. formcharacter=new QWidget(this);
    137. liste = new QComboBox();
    138. QHBoxLayout *layout = new QHBoxLayout;
    139. layout->addWidget(liste);
    140. formcharacter->setLayout(layout);
    141. formcharacter->show();
    142. }
    To copy to clipboard, switch view to plain text mode 
    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 ?
    Last edited by johan07; 15th November 2015 at 09:38.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: widget Position

    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.

  7. #7
    Join Date
    Dec 2012
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: widget Position

    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
    Last edited by johan07; 15th November 2015 at 20:03.

Similar Threads

  1. Replies: 4
    Last Post: 25th August 2015, 10:12
  2. Replies: 1
    Last Post: 7th August 2015, 12:22
  3. Replies: 2
    Last Post: 11th August 2014, 21:01
  4. Replies: 1
    Last Post: 11th April 2012, 07:45
  5. Getting a widget's position in desktop coords?
    By gfunk in forum Qt Programming
    Replies: 1
    Last Post: 5th January 2007, 06:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.