Results 1 to 7 of 7

Thread: QMdiArea + QWidget: no resize cursor

  1. #1
    Join Date
    Aug 2009
    Posts
    92
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QMdiArea + QWidget: no resize cursor

    I'm using the QMdiArea for a project and I add a couple of widgets to it:

    one is
    Qt Code:
    1. class FrameCreator : public QWidget
    To copy to clipboard, switch view to plain text mode 

    the other one is
    Qt Code:
    1. class Log : public QWidget
    To copy to clipboard, switch view to plain text mode 

    In the MainWindow I create the MdiArea:

    Qt Code:
    1. void MainWindow::Init()
    2. {
    3. m_MdiArea = new QMdiArea;
    4. m_MdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    5. m_MdiArea->setVerticalScrollBarPolicy (Qt::ScrollBarAsNeeded);
    6. setCentralWidget(m_MdiArea);
    7.  
    8. m_FrameCreatorGUI = new FrameCreator(this);
    9. m_MdiArea->addSubWindow(m_FrameCreatorGUI);
    10.  
    11. m_LogGUI = new Log(this);
    12. m_MdiArea->addSubWindow(m_LogGUI);
    13. }
    To copy to clipboard, switch view to plain text mode 


    Everything works fine but the GUIs don't show the "resize cursor" when I move the mouse on the corners.
    I can actually resize them, but I cannot see any "resize cursor".

    Shall I set something ?

    Forgot: ubuntu 10.04 and Qt 4.8 + Qt Creator 2.3.1

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMdiArea + QWidget: no resize cursor

    I guess you've messed something with events handling in your widgets.

    Try minimalistic example and see if the same happens:
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent)
    3. {
    4. QMdiArea* mdi = new QMdiArea();
    5.  
    6. QWidget* w = new QWidget();
    7. w->setMinimumSize( 100, 100 );
    8. mdi->addSubWindow( w );
    9.  
    10. this->setCentralWidget( mdi );
    11. }
    To copy to clipboard, switch view to plain text mode 
    For me it works fine on ubuntu 10.04 but I don't have qt4.8 to test.

  3. #3
    Join Date
    Aug 2009
    Posts
    92
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QMdiArea + QWidget: no resize cursor

    Yes, your example works.

    The funny thing is that one widget has the problem, the other one not.
    And they have the same identical options... no idea why it happens.

    Thanks, I'll write here if I find the cause/solution.

  4. #4
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMdiArea + QWidget: no resize cursor

    Look at event hangling for the widget that fails.
    Probably you're not calling base implementation somewhere which prevents cursor from being updated.

    Or post offending class here so people can take a look and help you.

  5. #5
    Join Date
    Aug 2009
    Posts
    92
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QMdiArea + QWidget: no resize cursor

    Ok, for example the Log GUI has the resize cursor problem.

    I post the ui file created by Qt:

    Qt Code:
    1. /********************************************************************************
    2. ** Form generated from reading UI file 'Log.ui'
    3. **
    4. ** Created: Mon Mar 5 15:07:18 2012
    5. ** by: Qt User Interface Compiler version 4.8.0
    6. **
    7. ** WARNING! All changes made in this file will be lost when recompiling UI file!
    8. ********************************************************************************/
    9.  
    10. #ifndef UI_LOG_H
    11. #define UI_LOG_H
    12.  
    13. #include <QtCore/QVariant>
    14. #include <QtGui/QAction>
    15. #include <QtGui/QApplication>
    16. #include <QtGui/QButtonGroup>
    17. #include <QtGui/QDialog>
    18. #include <QtGui/QFrame>
    19. #include <QtGui/QGridLayout>
    20. #include <QtGui/QGroupBox>
    21. #include <QtGui/QHBoxLayout>
    22. #include <QtGui/QHeaderView>
    23. #include <QtGui/QPushButton>
    24. #include <QtGui/QTextBrowser>
    25. #include <QtGui/QVBoxLayout>
    26.  
    27. QT_BEGIN_NAMESPACE
    28.  
    29. class Ui_Log
    30. {
    31. public:
    32. QGridLayout *gridLayout_2;
    33. QGroupBox *grpLog;
    34. QVBoxLayout *verticalLayout;
    35. QTextBrowser *txtLog;
    36. QFrame *frame;
    37. QHBoxLayout *horizontalLayout;
    38. QPushButton *btnLogClose;
    39. QPushButton *btnLogClear;
    40.  
    41. void setupUi(QDialog *Log)
    42. {
    43. if (Log->objectName().isEmpty())
    44. Log->setObjectName(QString::fromUtf8("Log"));
    45. Log->setWindowModality(Qt::NonModal);
    46. Log->resize(382, 635);
    47. QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    48. sizePolicy.setHorizontalStretch(0);
    49. sizePolicy.setVerticalStretch(0);
    50. sizePolicy.setHeightForWidth(Log->sizePolicy().hasHeightForWidth());
    51. Log->setSizePolicy(sizePolicy);
    52. Log->setMinimumSize(QSize(0, 0));
    53. Log->setStyleSheet(QString::fromUtf8(""));
    54. gridLayout_2 = new QGridLayout(Log);
    55. gridLayout_2->setObjectName(QString::fromUtf8("gridLayout_2"));
    56. grpLog = new QGroupBox(Log);
    57. grpLog->setObjectName(QString::fromUtf8("grpLog"));
    58. QSizePolicy sizePolicy1(QSizePolicy::Expanding, QSizePolicy::Expanding);
    59. sizePolicy1.setHorizontalStretch(0);
    60. sizePolicy1.setVerticalStretch(0);
    61. sizePolicy1.setHeightForWidth(grpLog->sizePolicy().hasHeightForWidth());
    62. grpLog->setSizePolicy(sizePolicy1);
    63. QFont font;
    64. font.setPointSize(12);
    65. font.setBold(true);
    66. font.setItalic(true);
    67. font.setWeight(75);
    68. grpLog->setFont(font);
    69. grpLog->setStyleSheet(QString::fromUtf8("QGroupBox {\n"
    70. " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
    71. " stop: 0 #A6CDD4, stop: 1 #FFFFFF);\n"
    72. " border: 2px solid gray;\n"
    73. " border-radius: 5px;\n"
    74. " margin-top: 1ex; /* leave space at the top for the title */\n"
    75. " }\n"
    76. "\n"
    77. " QGroupBox::title {\n"
    78. " subcontrol-origin: margin;\n"
    79. " subcontrol-position: top center; /* position at the top center */\n"
    80. " padding: 0 3px;\n"
    81. " }"));
    82. grpLog->setFlat(false);
    83. verticalLayout = new QVBoxLayout(grpLog);
    84. verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
    85. txtLog = new QTextBrowser(grpLog);
    86. txtLog->setObjectName(QString::fromUtf8("txtLog"));
    87. QFont font1;
    88. font1.setFamily(QString::fromUtf8("Courier New"));
    89. font1.setPointSize(8);
    90. txtLog->setFont(font1);
    91. txtLog->setStyleSheet(QString::fromUtf8(" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
    92. " stop: 0 #E0E0E0, stop: 1 #FFFFFF);\n"
    93. " border: 2px solid gray;\n"
    94. " border-radius: 5px;\n"
    95. ""));
    96.  
    97. verticalLayout->addWidget(txtLog);
    98.  
    99. frame = new QFrame(grpLog);
    100. frame->setObjectName(QString::fromUtf8("frame"));
    101. QSizePolicy sizePolicy2(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
    102. sizePolicy2.setHorizontalStretch(0);
    103. sizePolicy2.setVerticalStretch(0);
    104. sizePolicy2.setHeightForWidth(frame->sizePolicy().hasHeightForWidth());
    105. frame->setSizePolicy(sizePolicy2);
    106. frame->setMinimumSize(QSize(200, 34));
    107. frame->setStyleSheet(QString::fromUtf8(" QFrame {\n"
    108. " border: 1px solid black;\n"
    109. " border-radius: 4px;\n"
    110. " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
    111. " stop: 0 darkgray, stop: 1 #FFFFFF);\n"
    112. " }"));
    113. frame->setFrameShape(QFrame::StyledPanel);
    114. frame->setFrameShadow(QFrame::Raised);
    115. horizontalLayout = new QHBoxLayout(frame);
    116. horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
    117. horizontalLayout->setContentsMargins(-1, 4, -1, 4);
    118. btnLogClose = new QPushButton(frame);
    119. btnLogClose->setObjectName(QString::fromUtf8("btnLogClose"));
    120. QSizePolicy sizePolicy3(QSizePolicy::Minimum, QSizePolicy::Fixed);
    121. sizePolicy3.setHorizontalStretch(80);
    122. sizePolicy3.setVerticalStretch(20);
    123. sizePolicy3.setHeightForWidth(btnLogClose->sizePolicy().hasHeightForWidth());
    124. btnLogClose->setSizePolicy(sizePolicy3);
    125. btnLogClose->setMinimumSize(QSize(84, 20));
    126. btnLogClose->setMaximumSize(QSize(80, 20));
    127. btnLogClose->setCursor(QCursor(Qt::PointingHandCursor));
    128. btnLogClose->setStyleSheet(QString::fromUtf8(" QPushButton {\n"
    129. " border: 2px solid #8f8f91;\n"
    130. " border-radius: 4px;\n"
    131. " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
    132. " stop: 0 #f6f7fa, stop: 1 #dadbde);\n"
    133. " min-width: 80px;\n"
    134. " }\n"
    135. "\n"
    136. " QPushButton:pressed {\n"
    137. " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
    138. " stop: 0 #dadbde, stop: 1 #f6f7fa);\n"
    139. " }\n"
    140. "\n"
    141. " QPushButton:flat {\n"
    142. " border: none; /* no border for a flat push button */\n"
    143. " }\n"
    144. "\n"
    145. " QPushButton:default {\n"
    146. " border-color: navy; /* make the default button prominent */\n"
    147. " }"));
    148. btnLogClose->setAutoDefault(true);
    149. btnLogClose->setDefault(true);
    150.  
    151. horizontalLayout->addWidget(btnLogClose);
    152.  
    153. btnLogClear = new QPushButton(frame);
    154. btnLogClear->setObjectName(QString::fromUtf8("btnLogClear"));
    155. sizePolicy3.setHeightForWidth(btnLogClear->sizePolicy().hasHeightForWidth());
    156. btnLogClear->setSizePolicy(sizePolicy3);
    157. btnLogClear->setMinimumSize(QSize(84, 20));
    158. btnLogClear->setMaximumSize(QSize(80, 20));
    159. btnLogClear->setCursor(QCursor(Qt::PointingHandCursor));
    160. btnLogClear->setStyleSheet(QString::fromUtf8(" QPushButton {\n"
    161. " border: 2px solid #8f8f91;\n"
    162. " border-radius: 4px;\n"
    163. " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
    164. " stop: 0 #f6f7fa, stop: 1 #dadbde);\n"
    165. " min-width: 80px;\n"
    166. " }\n"
    167. "\n"
    168. " QPushButton:pressed {\n"
    169. " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
    170. " stop: 0 #dadbde, stop: 1 #f6f7fa);\n"
    171. " }\n"
    172. "\n"
    173. " QPushButton:flat {\n"
    174. " border: none; /* no border for a flat push button */\n"
    175. " }\n"
    176. "\n"
    177. " QPushButton:default {\n"
    178. " border-color: navy; /* make the default button prominent */\n"
    179. " }"));
    180.  
    181. horizontalLayout->addWidget(btnLogClear);
    182.  
    183.  
    184. verticalLayout->addWidget(frame);
    185.  
    186.  
    187. gridLayout_2->addWidget(grpLog, 0, 0, 1, 1);
    188.  
    189.  
    190. retranslateUi(Log);
    191.  
    192. QMetaObject::connectSlotsByName(Log);
    193. } // setupUi
    194.  
    195. void retranslateUi(QDialog *Log)
    196. {
    197. Log->setWindowTitle(QApplication::translate("Log", "LOG Gui", 0, QApplication::UnicodeUTF8));
    198. grpLog->setTitle(QString());
    199. #ifndef QT_NO_TOOLTIP
    200. btnLogClose->setToolTip(QApplication::translate("Log", "Close the window", 0, QApplication::UnicodeUTF8));
    201. #endif // QT_NO_TOOLTIP
    202. btnLogClose->setText(QApplication::translate("Log", "Close", 0, QApplication::UnicodeUTF8));
    203. #ifndef QT_NO_TOOLTIP
    204. btnLogClear->setToolTip(QApplication::translate("Log", "Clear the list", 0, QApplication::UnicodeUTF8));
    205. #endif // QT_NO_TOOLTIP
    206. btnLogClear->setText(QApplication::translate("Log", "Clear", 0, QApplication::UnicodeUTF8));
    207. } // retranslateUi
    208.  
    209. };
    210.  
    211. namespace Ui {
    212. class Log: public Ui_Log {};
    213. } // namespace Ui
    214.  
    215. QT_END_NAMESPACE
    216.  
    217. #endif // UI_LOG_H
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMdiArea + QWidget: no resize cursor

    Again - it works for me (ubuntu 10.04 but not qt4.8 though):
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent)
    3. {
    4. Ui::Log* l = new Ui::Log;
    5. QDialog* d = new QDialog();
    6. l->setupUi( d );
    7.  
    8. QMdiArea* area = new QMdiArea();
    9. area->addSubWindow( d );
    10.  
    11. this->setCentralWidget( area );
    12. }
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to Spitfire for this useful post:

    trallallero (6th March 2012)

  8. #7
    Join Date
    Aug 2009
    Posts
    92
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QMdiArea + QWidget: no resize cursor

    Found:

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent)
    3. {
    4. Ui::Log* l = new Ui::Log;
    5. QDialog* d = new QDialog();
    6. l->setupUi( d );
    7.  
    8. // This causes the problem if called from the MainWindow class !
    9. QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
    10.  
    11. QMdiArea* area = new QMdiArea();
    12. area->addSubWindow( d );
    13.  
    14. this->setCentralWidget( area );
    15. }
    To copy to clipboard, switch view to plain text mode 

    But thanks for helping me

Similar Threads

  1. Replies: 1
    Last Post: 22nd February 2012, 13:55
  2. QMdiArea slow resize of child windows
    By Tommytrojan in forum Qt Programming
    Replies: 0
    Last Post: 9th June 2010, 20:11
  3. Get QWidget pixel color below mouse Cursor
    By ^NyAw^ in forum Qt Programming
    Replies: 4
    Last Post: 24th May 2010, 17:17
  4. How to Disable or hide cursor from QWidget?
    By ashukla in forum Qt Programming
    Replies: 5
    Last Post: 17th October 2007, 14:42
  5. Resize QWidget in QMainWindow
    By aamer4yu in forum Qt Programming
    Replies: 1
    Last Post: 8th March 2007, 12:16

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.