PDA

View Full Version : QMdiArea + QWidget: no resize cursor



trallallero
1st March 2012, 14:48
I'm using the QMdiArea for a project and I add a couple of widgets to it:

one is
class FrameCreator : public QWidget

the other one is
class Log : public QWidget

In the MainWindow I create the MdiArea:


void MainWindow::Init()
{
m_MdiArea = new QMdiArea;
m_MdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded );
m_MdiArea->setVerticalScrollBarPolicy (Qt::ScrollBarAsNeeded);
setCentralWidget(m_MdiArea);

m_FrameCreatorGUI = new FrameCreator(this);
m_MdiArea->addSubWindow(m_FrameCreatorGUI);

m_LogGUI = new Log(this);
m_MdiArea->addSubWindow(m_LogGUI);
}



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

Spitfire
5th March 2012, 14:28
I guess you've messed something with events handling in your widgets.

Try minimalistic example and see if the same happens:

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
QMdiArea* mdi = new QMdiArea();

QWidget* w = new QWidget();
w->setMinimumSize( 100, 100 );
mdi->addSubWindow( w );

this->setCentralWidget( mdi );
}

For me it works fine on ubuntu 10.04 but I don't have qt4.8 to test.

trallallero
5th March 2012, 15:42
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.

Spitfire
5th March 2012, 16:28
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.

trallallero
6th March 2012, 07:43
Ok, for example the Log GUI has the resize cursor problem.

I post the ui file created by Qt:


/************************************************** ******************************
** Form generated from reading UI file 'Log.ui'
**
** Created: Mon Mar 5 15:07:18 2012
** by: Qt User Interface Compiler version 4.8.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
************************************************** ******************************/

#ifndef UI_LOG_H
#define UI_LOG_H

#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QDialog>
#include <QtGui/QFrame>
#include <QtGui/QGridLayout>
#include <QtGui/QGroupBox>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QPushButton>
#include <QtGui/QTextBrowser>
#include <QtGui/QVBoxLayout>

QT_BEGIN_NAMESPACE

class Ui_Log
{
public:
QGridLayout *gridLayout_2;
QGroupBox *grpLog;
QVBoxLayout *verticalLayout;
QTextBrowser *txtLog;
QFrame *frame;
QHBoxLayout *horizontalLayout;
QPushButton *btnLogClose;
QPushButton *btnLogClear;

void setupUi(QDialog *Log)
{
if (Log->objectName().isEmpty())
Log->setObjectName(QString::fromUtf8("Log"));
Log->setWindowModality(Qt::NonModal);
Log->resize(382, 635);
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(Log->sizePolicy().hasHeightForWidth());
Log->setSizePolicy(sizePolicy);
Log->setMinimumSize(QSize(0, 0));
Log->setStyleSheet(QString::fromUtf8(""));
gridLayout_2 = new QGridLayout(Log);
gridLayout_2->setObjectName(QString::fromUtf8("gridLayout_2"));
grpLog = new QGroupBox(Log);
grpLog->setObjectName(QString::fromUtf8("grpLog"));
QSizePolicy sizePolicy1(QSizePolicy::Expanding, QSizePolicy::Expanding);
sizePolicy1.setHorizontalStretch(0);
sizePolicy1.setVerticalStretch(0);
sizePolicy1.setHeightForWidth(grpLog->sizePolicy().hasHeightForWidth());
grpLog->setSizePolicy(sizePolicy1);
QFont font;
font.setPointSize(12);
font.setBold(true);
font.setItalic(true);
font.setWeight(75);
grpLog->setFont(font);
grpLog->setStyleSheet(QString::fromUtf8("QGroupBox {\n"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0 #A6CDD4, stop: 1 #FFFFFF);\n"
" border: 2px solid gray;\n"
" border-radius: 5px;\n"
" margin-top: 1ex; /* leave space at the top for the title */\n"
" }\n"
"\n"
" QGroupBox::title {\n"
" subcontrol-origin: margin;\n"
" subcontrol-position: top center; /* position at the top center */\n"
" padding: 0 3px;\n"
" }"));
grpLog->setFlat(false);
verticalLayout = new QVBoxLayout(grpLog);
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
txtLog = new QTextBrowser(grpLog);
txtLog->setObjectName(QString::fromUtf8("txtLog"));
QFont font1;
font1.setFamily(QString::fromUtf8("Courier New"));
font1.setPointSize(8);
txtLog->setFont(font1);
txtLog->setStyleSheet(QString::fromUtf8(" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0 #E0E0E0, stop: 1 #FFFFFF);\n"
" border: 2px solid gray;\n"
" border-radius: 5px;\n"
""));

verticalLayout->addWidget(txtLog);

frame = new QFrame(grpLog);
frame->setObjectName(QString::fromUtf8("frame"));
QSizePolicy sizePolicy2(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
sizePolicy2.setHorizontalStretch(0);
sizePolicy2.setVerticalStretch(0);
sizePolicy2.setHeightForWidth(frame->sizePolicy().hasHeightForWidth());
frame->setSizePolicy(sizePolicy2);
frame->setMinimumSize(QSize(200, 34));
frame->setStyleSheet(QString::fromUtf8(" QFrame {\n"
" border: 1px solid black;\n"
" border-radius: 4px;\n"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0 darkgray, stop: 1 #FFFFFF);\n"
" }"));
frame->setFrameShape(QFrame::StyledPanel);
frame->setFrameShadow(QFrame::Raised);
horizontalLayout = new QHBoxLayout(frame);
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
horizontalLayout->setContentsMargins(-1, 4, -1, 4);
btnLogClose = new QPushButton(frame);
btnLogClose->setObjectName(QString::fromUtf8("btnLogClose"));
QSizePolicy sizePolicy3(QSizePolicy::Minimum, QSizePolicy::Fixed);
sizePolicy3.setHorizontalStretch(80);
sizePolicy3.setVerticalStretch(20);
sizePolicy3.setHeightForWidth(btnLogClose->sizePolicy().hasHeightForWidth());
btnLogClose->setSizePolicy(sizePolicy3);
btnLogClose->setMinimumSize(QSize(84, 20));
btnLogClose->setMaximumSize(QSize(80, 20));
btnLogClose->setCursor(QCursor(Qt::PointingHandCursor));
btnLogClose->setStyleSheet(QString::fromUtf8(" QPushButton {\n"
" border: 2px solid #8f8f91;\n"
" border-radius: 4px;\n"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0 #f6f7fa, stop: 1 #dadbde);\n"
" min-width: 80px;\n"
" }\n"
"\n"
" QPushButton:pressed {\n"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0 #dadbde, stop: 1 #f6f7fa);\n"
" }\n"
"\n"
" QPushButton:flat {\n"
" border: none; /* no border for a flat push button */\n"
" }\n"
"\n"
" QPushButton:default {\n"
" border-color: navy; /* make the default button prominent */\n"
" }"));
btnLogClose->setAutoDefault(true);
btnLogClose->setDefault(true);

horizontalLayout->addWidget(btnLogClose);

btnLogClear = new QPushButton(frame);
btnLogClear->setObjectName(QString::fromUtf8("btnLogClear"));
sizePolicy3.setHeightForWidth(btnLogClear->sizePolicy().hasHeightForWidth());
btnLogClear->setSizePolicy(sizePolicy3);
btnLogClear->setMinimumSize(QSize(84, 20));
btnLogClear->setMaximumSize(QSize(80, 20));
btnLogClear->setCursor(QCursor(Qt::PointingHandCursor));
btnLogClear->setStyleSheet(QString::fromUtf8(" QPushButton {\n"
" border: 2px solid #8f8f91;\n"
" border-radius: 4px;\n"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0 #f6f7fa, stop: 1 #dadbde);\n"
" min-width: 80px;\n"
" }\n"
"\n"
" QPushButton:pressed {\n"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0 #dadbde, stop: 1 #f6f7fa);\n"
" }\n"
"\n"
" QPushButton:flat {\n"
" border: none; /* no border for a flat push button */\n"
" }\n"
"\n"
" QPushButton:default {\n"
" border-color: navy; /* make the default button prominent */\n"
" }"));

horizontalLayout->addWidget(btnLogClear);


verticalLayout->addWidget(frame);


gridLayout_2->addWidget(grpLog, 0, 0, 1, 1);


retranslateUi(Log);

QMetaObject::connectSlotsByName(Log);
} // setupUi

void retranslateUi(QDialog *Log)
{
Log->setWindowTitle(QApplication::translate("Log", "LOG Gui", 0, QApplication::UnicodeUTF8));
grpLog->setTitle(QString());
#ifndef QT_NO_TOOLTIP
btnLogClose->setToolTip(QApplication::translate("Log", "Close the window", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_TOOLTIP
btnLogClose->setText(QApplication::translate("Log", "Close", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
btnLogClear->setToolTip(QApplication::translate("Log", "Clear the list", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_TOOLTIP
btnLogClear->setText(QApplication::translate("Log", "Clear", 0, QApplication::UnicodeUTF8));
} // retranslateUi

};

namespace Ui {
class Log: public Ui_Log {};
} // namespace Ui

QT_END_NAMESPACE

#endif // UI_LOG_H

Spitfire
6th March 2012, 12:29
Again - it works for me (ubuntu 10.04 but not qt4.8 though):


MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
Ui::Log* l = new Ui::Log;
QDialog* d = new QDialog();
l->setupUi( d );

QMdiArea* area = new QMdiArea();
area->addSubWindow( d );

this->setCentralWidget( area );
}

trallallero
6th March 2012, 12:59
Found:



MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
Ui::Log* l = new Ui::Log;
QDialog* d = new QDialog();
l->setupUi( d );

// This causes the problem if called from the MainWindow class !
QApplication::setOverrideCursor(QCursor(Qt::ArrowC ursor));

QMdiArea* area = new QMdiArea();
area->addSubWindow( d );

this->setCentralWidget( area );
}


But thanks for helping me :)