免責聲明,我只是今天剛剛下載Qt並沒有經驗。所以我很抱歉,如果這有點愚蠢。得從某處開始:)。我可以在QPolygon上使用SIGNAL/SLOT嗎?
我將使用[thing1]和[thing2],1是GraphicsWidget中的qpolygon,2是Widget。
[thing1] = scene->addPolygon([pathname],Pen,Brush)
ui->[thing2]->hide();
connect([thing1],SIGNAL(hovered()),ui->[thing2],SLOT(show()));
我試圖隱藏在鼠標懸停事件/節目,但我得到的錯誤
D:\Documents\Test\GUI\mainwindow.cpp:61: error: no matching function for call to 'MainWindow::connect(QGraphicsPolygonItem*&, const char*, MainWindow*, QTextEdit*&, const char*)'
connect([thing1],SIGNAL(hovered()),this,ui->[thing2],SLOT(show()));
^
如果您沒有經驗,請先閱讀文檔和教程。對於信號/插槽:類的文檔告訴你每個類有什麼信號/插槽。 QPolygon例如沒有信號叫做hovered()。但是,stackoverflow不會替代你的教程。你應該首先對事物有一些基本的瞭解。 – Hayt
錯誤消息與您發佈的代碼不符。該錯誤是關於一個調用連接5個參數傳遞,您的代碼通過4. – Mat
相關問題:http://stackoverflow.com/questions/2940392/qgraphicsitem-doesnt-receive-mouse-hover-events –