1

Hello I'm trying to connect to my QFrame component using lambda inside QMainWindow construct but I get error

Qwidget::mousePressEvent, cannot access protected member declared in class 'QWidget'

Here is my code

QtTestWindow::QtTestWindow(QWidget *parent):QMainWindow(parent)
{

connect( ui.TopFrame, &QFrame::mousePressEvent, [=]
{

});
ui.setupUi( this );

}
6
  • isn't it connect(&src, &signal(), &dst, &slot())? where is your destination? Commented Apr 4, 2015 at 23:12
  • @user3528438 that's the old syntax, the new one should be preferred Commented Apr 4, 2015 at 23:20
  • @user29 What are you trying to achieve? Commented Apr 4, 2015 at 23:24
  • @AlejandroDíaz No it isn't. In both new and old there is a 4-argument and a 3-argument version. connect() 1 and connect() 3. The 3-argument version is "Equivalent to connect(sender, signal, this, method, type)." Commented Apr 5, 2015 at 7:56
  • @SimonWarta in that website there's an example showing the new syntax with a lambda function QObject::connect(socket, &QTcpSocket::connected, [=] () { socket->write("GET " + page + "\r\n"); }); , I think I'm missing your point Commented Apr 5, 2015 at 12:16

1 Answer 1

3

The QFrame class extents QWidget and the function is signature is

void QWidget::mousePressEvent(QMouseEvent * event) [virtual protected]

In other words this is not a signal and you cannot do what you're trying.

For completeness here's the documented signature of a signal

void QWidget::customContextMenuRequested(const QPoint & pos) [signal]

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.