2013年9月10日星期二

Inherits QWidget class mousePressEvent did not respond ?

Inherits QWidget class mousePressEvent and mouseReleaseEvent did not respond ?

AHostList.h

class AHostList: public QWidget
{
Q_OBJECT
public:
AHostList (QString & path);
~ AHostList ();
void mousePressEvent (QMouseEvent * event);
void mouseReleaseEvent (QMouseEvent * event);

};



AHostList.cpp:

AHostList :: AHostList (QString & path)
{
this-> setCursor (Qt :: BlankCursor);
setWindowFlags (Qt :: FramelessWindowHint);

m_mainWidget = new QListWidget (this);
char * pFirstText = "NAME SIZE TIME ";
m_firstLabel = new QLabel (this);
m_firstLabel-> setFont (QFont ("Helvetica", 14, QFont :: Bold, 0));
m_firstLabel-> setStyleSheet ("QLabel {background-color: blue}");
m_firstLabel-> setText (pFirstText);
m_firstLabel-> resize (800,35);

QDir picdir (path);
fileList = picdir.entryInfoList ();
QFileInfo fileInfo;
QString fileText;

m_sumItem = 0;
m_itemCount = (int) fileList.count ();
/ / start at 2 because there are ...
for (int i = 2; i fileInfo = fileList.at (i);
fileText + = fileInfo.fileName ();
fileText + = "";
fileText + = QString :: number (fileInfo.size ());
fileText + = "K";
QString format ("MM-dd hh: mm: ss");
/ / Last modified time
fileText + = fileInfo.lastModified (). toString (format);
pListWidgetItem [i-2] = new QListWidgetItem (fileText, m_mainWidget);
pListWidgetItem [i-2] -> setSizeHint (QSize (800,40));
m_mainWidget-> addItem (pListWidgetItem [i-2]);

m_sumItem + +;
if (i> = 51)
break;
fileText = "";
}
m_mainWidget-> setCurrentRow (0);
m_mainWidget-> resize (800,440);
m_mainWidget-> move (2,40);
m_mainWidget-> setFocus ();
show ();
}

void AHostList :: mousePressEvent (QMouseEvent * event)
{
qDebug () << "!!!!!!!!!!";
/ / QWidget :: mousePressEvent (event);
}

void AHostList :: mouseReleaseEvent (QMouseEvent * event)
{
qDebug () << "| | | | | | | |";
}
no printed information , but move your finger over the touch screen a list of possible moves

------ Solution ------------------------------------ --------
these mouseEvent is protected virtual function in QtCreator Lane is in italics .
certain point where there is no control will be effective .
------ Solution ---------------------------------------- ----

  
  
" No Control" specifically refers to what ?  
no control is : Assuming only one button on a form , where no controls are outside the area where the button , the form in the space .
------ For reference only -------------------------------------- -



" No Control" specifically refers to what ?
------ For reference only -------------------------------------- -
in this constructor calls about this sentence :
this-> setMouseTracking (true);
------ For reference only ------------------------- --------------
problems have been solved , though not downstairs said method , but still thank you
to the sub
------ For reference only -------------------------------- -------
I was overloaded on the mousePressEvent QWidget event , but that does not enter the event , but in the video on this QWidget .

没有评论:

发表评论