Ich googelte herum und fand this forum thread, in dem das OP das genaue Problem zu haben scheint, das ich habe. Die Frage ist, wie würde ich von QLabel
erben und das mousepressed Ereignis neu implementieren? Ich vermute, es wäre so etwas wie dieses:Die Mausklickposition eines Etiketts in Qt bekommen
class CustomLabel : public QLabel
{
public:
//what about the constructors?
void mousePressEvent (QMouseEvent * ev);
}
void CustomLabel::mousePressEvent (QMouseEvent * ev)
{
QPoint = ev->pos();
//I want to have another function get the event position.
//How would I achieve this? It's void!
//Is there perhaps some way to set up a signal and slot with the position?
}
Und nachdem ich erfolgreich eine CustomLabel
Klasse erstellt haben, wie würde ich in der Lage sein, es in der Entwurfsansicht zu setzen?
Haben Sie die zweite Lösung das Etikett wieder in das Hauptfenster des Setzens? – arqam