Results 1 to 8 of 8

Thread: QTabWidget->setCornerWidget() unexpected resize.

  1. #1
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QTabWidget->setCornerWidget() unexpected resize.

    Hello people,

    I'm experiencing some strange behavior with the following set up:
    - I'm using QT 4.2.x (Replace .x with the standard Edgy packaged version).
    - I create a class which herits from QTabWidget, and dynamicaly creates sub widgets (Tabs).
    - I also have created a little other QWidget derived class (With QTDesigner, named CEditorTabButtons) then a subclass which implements it. It is a simple qwidget with inside several QToolButtons. All the QToolsButtons are layed out with a default horizontal boxing.
    - In the constructor of the "Tab manager" class, i do:
    Qt Code:
    1. pButtonsBar = new CEditorTabButtonsImpl(this);
    2. setCornerWidget(pButtonsBar);
    To copy to clipboard, switch view to plain text mode 

    Then here comes the strange thing:
    If i have only one tab in the tab container, the "corner buttons" are kind of stacked (If i give them a minimal size). They are also resized to very tiny size (If i give them no minimal size). After i add another tab, the buttons have almost their right size, and with more than 2 tabs they have the right size and stop changing size (Until i remove tabs again, they becomes small).

    So i tried to tell my CEditorTabButtonsImpl to have a fixed size, the result is that when i only have 1 tab, the box "slides" to the right, and as a result i'm only able to see the 2 first buttons (The others are out of the window).

    Resizing the main application window does nothing.

    Anyone has a clue on what i'm doing wrong here?

    Thanks a lot,
    Pierre.

    [EDIT:] Just to make thinks a bit more clear: what i'm trying to achieve is a simple tabbed based text editor. So the tools buttons in the tab bar i'm talking about are like such this kind of tool usualy have (With save, open, new close icons). I hope you'll see what i mean
    [EDIT2:] Just added 4 screens of what's appening
    Attached Images Attached Images
    Last edited by hickscorp; 8th December 2006 at 01:46.

  2. #2
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTabWidget->setCornerWidget() unexpected resize.

    Up?
    I have attached pictures of the visual i have in my previous post.
    If no one can help, can someone please gives me a clue on where to search for this information?

    Thanks,
    Pierre.

  3. #3
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTabWidget->setCornerWidget() unexpected resize.

    Up?...

    Should i ask to the QT programming team, or is my mistake so obvious that people doesn't want to answer ?

    Thanks,
    Pierre.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTabWidget->setCornerWidget() unexpected resize.

    I'm sure a minimal compilable example reproducing the problem would raise people's interest towards the problem..
    J-P Nurmi

  5. #5
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTabWidget->setCornerWidget() unexpected resize.

    Hello JPN and thanks for your suggestion.

    I will try to make here an example closest as i can to what i'm trying to do.

    So first, i have created this .UI, which is the content i want to appear in my tabs:
    Qt Code:
    1. <ui version="4.0" >
    2. <class>CEditorTab</class>
    3. <widget class="QWidget" name="CEditorTab" >
    4. <property name="geometry" >
    5. <rect>
    6. <x>0</x>
    7. <y>0</y>
    8. <width>681</width>
    9. <height>611</height>
    10. </rect>
    11. </property>
    12. <property name="windowTitle" >
    13. <string>Editor Tab</string>
    14. </property>
    15. <layout class="QHBoxLayout" >
    16. <property name="margin" >
    17. <number>0</number>
    18. </property>
    19. <property name="spacing" >
    20. <number>0</number>
    21. </property>
    22. <item>
    23. <widget class="QTextEdit" name="txtEditor" >
    24. <property name="font" >
    25. <font>
    26. <family>Monospace</family>
    27. <pointsize>8</pointsize>
    28. <weight>50</weight>
    29. <bold>false</bold>
    30. <antialiasing>true</antialiasing>
    31. <kerning>true</kerning>
    32. </font>
    33. </property>
    34. <property name="frameShape" >
    35. <enum>QFrame::NoFrame</enum>
    36. </property>
    37. <property name="lineWrapMode" >
    38. <enum>QTextEdit::NoWrap</enum>
    39. </property>
    40. </widget>
    41. </item>
    42. </layout>
    43. </widget>
    44. <tabstops>
    45. <tabstop>txtEditor</tabstop>
    46. </tabstops>
    47. <resources>
    48. <include location="Artwork/Resources.qrc" />
    49. </resources>
    50. <connections/>
    51. </ui>
    To copy to clipboard, switch view to plain text mode 

    Then, i have created this .UI, which is a QWidget containing various buttons i want to show on the top right corner of my QTabWidget:
    Qt Code:
    1. <ui version="4.0" >
    2. <class>CEditorTabButtons</class>
    3. <widget class="QWidget" name="CEditorTabButtons" >
    4. <property name="geometry" >
    5. <rect>
    6. <x>0</x>
    7. <y>0</y>
    8. <width>100</width>
    9. <height>22</height>
    10. </rect>
    11. </property>
    12. <property name="sizePolicy" >
    13. <sizepolicy>
    14. <hsizetype>0</hsizetype>
    15. <vsizetype>0</vsizetype>
    16. <horstretch>0</horstretch>
    17. <verstretch>0</verstretch>
    18. </sizepolicy>
    19. </property>
    20. <property name="windowTitle" >
    21. <string>Editor Buttons</string>
    22. </property>
    23. <layout class="QGridLayout" >
    24. <property name="margin" >
    25. <number>0</number>
    26. </property>
    27. <property name="spacing" >
    28. <number>2</number>
    29. </property>
    30. <item row="0" column="5" >
    31. <widget class="QToolButton" name="btnClose" >
    32. <property name="minimumSize" >
    33. <size>
    34. <width>18</width>
    35. <height>18</height>
    36. </size>
    37. </property>
    38. <property name="maximumSize" >
    39. <size>
    40. <width>20</width>
    41. <height>20</height>
    42. </size>
    43. </property>
    44. <property name="text" >
    45. <string/>
    46. </property>
    47. <property name="icon" >
    48. <iconset resource="Artwork/Resources.qrc" >:/Images/RedCross.png</iconset>
    49. </property>
    50. </widget>
    51. </item>
    52. <item row="0" column="4" >
    53. <widget class="QToolButton" name="btnNew" >
    54. <property name="minimumSize" >
    55. <size>
    56. <width>18</width>
    57. <height>18</height>
    58. </size>
    59. </property>
    60. <property name="maximumSize" >
    61. <size>
    62. <width>20</width>
    63. <height>20</height>
    64. </size>
    65. </property>
    66. <property name="text" >
    67. <string/>
    68. </property>
    69. <property name="icon" >
    70. <iconset resource="Artwork/Resources.qrc" >:/Images/NewFile.png</iconset>
    71. </property>
    72. </widget>
    73. </item>
    74. <item row="0" column="3" >
    75. <widget class="QToolButton" name="btnOpen" >
    76. <property name="minimumSize" >
    77. <size>
    78. <width>18</width>
    79. <height>18</height>
    80. </size>
    81. </property>
    82. <property name="maximumSize" >
    83. <size>
    84. <width>20</width>
    85. <height>20</height>
    86. </size>
    87. </property>
    88. <property name="text" >
    89. <string/>
    90. </property>
    91. <property name="icon" >
    92. <iconset resource="Artwork/Resources.qrc" >:/Images/Folder.png</iconset>
    93. </property>
    94. </widget>
    95. </item>
    96. <item row="0" column="2" >
    97. <widget class="QToolButton" name="btnSaveAll" >
    98. <property name="minimumSize" >
    99. <size>
    100. <width>18</width>
    101. <height>18</height>
    102. </size>
    103. </property>
    104. <property name="maximumSize" >
    105. <size>
    106. <width>20</width>
    107. <height>20</height>
    108. </size>
    109. </property>
    110. <property name="text" >
    111. <string/>
    112. </property>
    113. <property name="icon" >
    114. <iconset resource="Artwork/Resources.qrc" >:/Images/SaveAll.png</iconset>
    115. </property>
    116. </widget>
    117. </item>
    118. <item row="0" column="1" >
    119. <widget class="QToolButton" name="btnSave" >
    120. <property name="minimumSize" >
    121. <size>
    122. <width>18</width>
    123. <height>18</height>
    124. </size>
    125. </property>
    126. <property name="maximumSize" >
    127. <size>
    128. <width>20</width>
    129. <height>20</height>
    130. </size>
    131. </property>
    132. <property name="text" >
    133. <string/>
    134. </property>
    135. <property name="icon" >
    136. <iconset resource="Artwork/Resources.qrc" >:/Images/Save.png</iconset>
    137. </property>
    138. </widget>
    139. </item>
    140. <item row="0" column="0" >
    141. <spacer>
    142. <property name="orientation" >
    143. <enum>Qt::Horizontal</enum>
    144. </property>
    145. <property name="sizeHint" >
    146. <size>
    147. <width>118</width>
    148. <height>22</height>
    149. </size>
    150. </property>
    151. </spacer>
    152. </item>
    153. </layout>
    154. </widget>
    155. <resources>
    156. <include location="Artwork/Resources.qrc" />
    157. </resources>
    158. <connections/>
    159. </ui>
    To copy to clipboard, switch view to plain text mode 

    Then i have this class (Which is simplified for the example):
    Qt Code:
    1. #ifndef CEditorTabBar_h
    2. #define CEditorTabBar_h
    3.  
    4. #include <QTabWidget>
    5.  
    6. // This is the little class containing the corner buttons, which i have derived to put some file open / close code in it...
    7. class CEditorTabButtonsImpl;
    8. class CEditorTabImpl;
    9.  
    10. class CEditorTabBar :
    11. public QTabWidget {
    12.  
    13. Q_OBJECT
    14.  
    15. public:
    16. // Constructor.
    17. CEditorTabBar(QWidget* Parent=0) :
    18. QTabWidget(parent) {
    19.  
    20. pButtonsBar = new CEditorTabButtonsImpl(this);
    21. setCornerWidget(pButtonsBar);
    22. }
    23. // Destructor etc also....
    24.  
    25. cPath);
    26.  
    27. // Then only slots and signals here.
    28. };
    29.  
    30. #endif
    To copy to clipboard, switch view to plain text mode 

    Then on my main window class, i have code similar to this:
    Qt Code:
    1. QFont cLittleFont;
    2. cLittleFont.setPointSize(7);
    3. pEditorTabBar = new CEditorTabBar(this);
    4. pEditorTabBar->setFont(cLittleFont);
    5. setCentralWidget(pEditorTabBar);
    To copy to clipboard, switch view to plain text mode 

    It creates the Tab Bar, but as shown on pictures on my first thread, the corner buttons are messed up...

    Here we are, i hope this will help helping me
    Thanks,
    Pierre.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTabWidget->setCornerWidget() unexpected resize.

    Please attach large amounts of code as a file archive instead of pasting it directly in your post

  7. #7
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTabWidget->setCornerWidget() unexpected resize.

    Hello Wysota,

    I can't edit my post to do as you suggest, any way to delete the thread so i can create a "clean" one?

    Thanks,
    Pierre.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTabWidget->setCornerWidget() unexpected resize.

    There is no need for that - what is done is done.

Similar Threads

  1. postponing resize event
    By Honestmath in forum Qt Programming
    Replies: 11
    Last Post: 26th February 2006, 00:32

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.