Qt 5 Programm stürzt ab

Hi Leute ich wollte ein Test Programm programmieren.

Jetzt hab ich ein Problem und zwar mein Programm stürzt dauernd ab!

Hier sind die Codes(kdwindow.h):

#ifndef KDWINDOW_H
#define KDWINDOW_H
#include <QMainWindow>
#include <QPushButton>
#include <QLabel>
#include <QLayout>

namespace Ui {
    class KdWindow;
}

class KdWindow : public QMainWindow {
    Q_OBJECT

public:
    explicit KdWindow(QWidget *parent = 0);

private slots:
    void btnPressed();

private:
    QPushButton *btn;
    QLabel *label;

};


#endif // KDWINDOW_H

kdwindow.cpp:

#include "kdwindow.h"
#include <QCoreApplication>

KdWindow::KdWindow(QWidget *parent) : QMainWindow (parent) {
    label = new QLabel;
    label -> setText("Das ist ein einfacher Text");
    btn = new QPushButton("Klicken!", this);
    connect(btn, SIGNAL(clicked()), this, SLOT(btnPressed()));
    QVBoxLayout *vlayout = new QVBoxLayout;
    vlayout -> addWidget(label);
    vlayout -> addWidget(btn);
    setLayout(vlayout);
    setWindowTitle("KD Berechnung");
}

void KdWindow::btnPressed() {
    btn -> setText("Nochmal!");
}

und zu guter letzt die main.cpp:

#include "kdwindow.h"
#include <QApplication>

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);
    KdWindow kdWindow;
    kdWindow.show();
    return app.exec();
}

Und die Fehler Meldung(naja mehr oder weniger):

Starte /Users/niklas/Documents/programming/Qt/build-KD-Desktop_Qt_5_4_0_clang_64bit-Debug/KD.app/Contents/MacOS/KD...
Das Programm ist abgestürzt.
/Users/niklas/Documents/programming/Qt/build-KD-Desktop_Qt_5_4_0_clang_64bit-Debug/KD.app/Contents/MacOS/KD ist abgestürzt
Programm, CPP, Qt, Absturz
qt-Programm: QLineEdit mit QPushButton auslesen funktioniert nicht, warum?

Hallo, ich versuche im 2 Fenster 2 des unteren Proggis Text der unteren QLineEdit nach oben zu übernehmen (mit testen ()), stürzt ab und wird oben(QlineEdit) nicht angezeigt . Warum klappt es nicht, bin Neuling in QT? Hier Counter.h: #include QLineEdit #include QPushButton #include QDialog

class Counter : public  QLineEdit
{
Q_OBJECT // Enable signals and slots
public:
Counter (QWidget *parent=0);
~Counter();
QPushButton *cl, *plus;  
QWidget *fen;
public slots:
 void countUp();
 void testen();
void MeinFenster(); 
private:
char zahlwort[200];
Counter *gf, *hf;
int n;
QString zahli;
};

hier Counter.cpp

#include "counter.h"
Counter::Counter (QWidget *parent)
  : QLineEdit (parent),
 n(0){}
 Counter::~Counter() {}
 void Counter :: MeinFenster() //QWidget parent)
 {
  fen = new QWidget();
 fen->setGeometry(100,200,300,200);
  fen->show();
  gf = new Counter(fen); // Eigentlich als Eingabe gedacht
  gf->setGeometry(10,10,100,20);
  gf->show();
  hf = new Counter(fen); // Als Ausgabe der Berechnungen gedacht
  hf->setGeometry(10,50,100,20);
  hf->show();
  hf->setText(zahli);
  cl = new QPushButton("test", fen);
  cl->setGeometry(50,120,95,20);
  cl->show();
  plus = new QPushButton("plus", fen);
  plus->setGeometry(50,150,95,20);
  plus->show();
  QObject::connect(cl, SIGNAL (clicked()), gf, SLOT(testen()));
  QObject::connect(plus, SIGNAL (clicked()), hf, SLOT(countUp()));
 }
 void Counter::countUp ()
 {
 zahli = text();
 n = zahli.toInt();
 n++;
 zahli.setNum(n);
 setText(zahli);
 }
 void Counter :: testen()
 {
  zahli = hf->text();
  setText(zahli);
 }
Counter::Counter (QWidget *parent)
 : QLineEdit (parent),
 n(0){}
 Counter::~Counter() {}
 void Counter :: MeinFenster() //QWidget parent)
 {
fen = new QWidget();
fen->setGeometry(100,200,300,200);
    fen->show();
gf = new Counter(fen); // Eigentlich als Eingabe gedacht
gf->setGeometry(10,10,100,20);
gf->show();
 hf = new Counter(fen); // Als Ausgabe der Berechnungen gedacht
 hf->setGeometry(10,50,100,20);
 hf->show();
hf->setText(zahli);
 cl = new QPushButton("test", fen);
 cl->setGeometry(50,120,95,20);
cl->show();
plus = new QPushButton("plus", fen);
plus->setGeometry(50,150,95,20);
    plus->show();
 QObject::connect(cl, SIGNAL (clicked()), gf, SLOT(testen()));
 QObject::connect(plus, SIGNAL (clicked()), hf, SLOT(countUp()));
}
void Counter::countUp ()
 {
 zahli = text();
 n = zahli.toInt();
 n++;
zahli.setNum(n);
 setText(zahli);
 }
 void Counter :: testen()
 {
  zahli = hf->text();
  setText(zahli);
 }

soll hf->text() heißen main.cpp = okay. Kann nicht auf Text der anderen mit Counter gesetzten QLineEdit-Elemente zurückgreifen. CountUp= ok.. Wird ohne Fehler / Warnmeldungen compiliert. Aber wenn ich versuche mit testen gf->text auf den Text vom Element gf zurückzugreifen will, stürzt das Prog ab. setText("hallo") wird angezeigt warum? Falsche Klasse oder was?

Text, Qt, slots
PyQT6 Code - Zufällige Buchstaben?

Ich habe diesen Code geschrieben:

import random
import sys
from PyQt6.QtCore import Qt, QSize
from PyQt6.QtGui import QPixmap, QFont
from PyQt6.QtWidgets import QApplication, QLabel, QMainWindow, QPushButton
from PyQt6.QtWidgets import (
    QApplication,
    QCheckBox,
    QComboBox,
    QDateEdit,
    QDateTimeEdit,
    QToolBar,
    QDial,
    QDoubleSpinBox,
    QFontComboBox,
    QLabel,
    QLCDNumber,
    QLineEdit,
    QMainWindow,
    QProgressBar,
    QPushButton,
    QRadioButton,
    QSlider,
    QSpinBox,
    QTimeEdit,
    QVBoxLayout,
    QWidget,
)


from PyQt6.QtWidgets import (QWidget, QLabel, QLineEdit,
        QTextEdit, QGridLayout, QApplication)


class SushiCreator(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setFixedSize(QSize(300, 200))
        self.setWindowTitle("Sushi Creator")
        self.setStyleSheet("background-color: lightblue;")


        self.start_button = QPushButton("Starten", self)
        self.start_button.move(105, 75)
        self.start_button.clicked.connect(self.start_clicked)
        
    def start_clicked(self):
        self.setFixedSize(QSize(1000, 1000))
        self.start_button.hide()


        letters = 'a' + 'b'+ 'c' + 'd' + 'e' + 'f' + 'g' + 'a' + 'h' + 'c'  
        random_letters = ''.join(random.choice(letters) for i in range(5))


        


        self.letters_edit = QPushButton(self)
        self.letters_edit.setText(random_letters)
        self.letters_edit.setFont(QFont("Arial", 200))
        self.letters_edit.setStyleSheet("background-color: cyan; color: black;")
        
        
     
        
    
        


if __name__ == '__main__':
    app = QApplication(sys.argv)
    sushi_creator = SushiCreator()
    sushi_creator.show()
    sys.exit(app.exec())

Es entsteht ein hellblaues Fenster mit einem "Start" Knopf. Nach Betätigung wird dieser versteckt und das Fenster groß. Leider sind keine Buchstaben zu sehen. Kann mir jemand helfen?

Programmiersprache, Python, Qt, Python 3
Qt/QML Eine ScrollBar für ein TextField erstellen?

Hey,

ich möchte eine ScrollBar in Qt für ein TextField erstellen. Außerdem soll wenn man Text auswählt den man eingegeben hat und Rechts-Klick macht, ein Pop Up Menü angezeigt werden bei dem man Optionen wie z.B "Einfügen" oder "Kopieren" hat.

Wenn ich den Folgenden Code ausführe bekomme ich 2 Fehler:

  1. qrc:/main.qml:89:26: QML Rectangle: Binding loop detected for property "implicitWidth"
  2. qrc:/main.qml:89:26: QML Rectangle: Binding loop detected for property "implicitHeight"

Hier die main.qml:

import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.5

ApplicationWindow {
   id: mainWindow
   visible: true
   width: 900
   height: 600
   title: qsTr("Hello World")
    
    
   TextField {
       id: textFieldForURL
       width: parent.width/2
       height: parent.height/14
       y: parent.height/4
       x: -scrollBar1.position * width
    
       anchors.centerIn: parent
       leftPadding: 8
       topPadding: 4
       rightPadding: 43
    
       color: "white"
       font.pixelSize: parent.height/20
       selectionColor: "#3b3d45"
       placeholderText: "Type something"
       placeholderTextColor: "#3b3f44"
       selectByMouse: true
       maximumLength: 1000
  
       background: Rectangle {
          id: textFieldForURL_Background
          color: "black"
          radius: 5
  
          Rectangle {
             id: clearTextFieldForURL_Background
             width: parent.height
             height: parent.height
             anchors.right: parent.right
             color: "black"
          }
       }
  
      Text {
         id: clearTextFieldForURL
         height: parent.height
         width: parent.height
         text: "X"
         color: "white"
         font.pixelSize: 30
         anchors.right: parent.right
         leftPadding: 13
  
         MouseArea {
            id: clearTextFieldForURL_MouseArea
            height: textFieldForURL.height
            width: textFieldForURL.height
            hoverEnabled: true
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.verticalCenter: parent.verticalCenter
  
            onClicked: {
               textFieldForURL.text = ""
               textFieldForURL.forceActiveFocus()
            }
            onEntered: {
               clearTextFieldForURL_Background.color = "#2a2c30"
            }
            onExited: {
               clearTextFieldForURL_Background.color = "black"
            }
         }
      }

      ScrollBar {
         id: scrollBar1
         hoverEnabled: true
         active: hovered || pressed
         orientation: Qt.Horizontal
         size: textFieldForURL_Background.width / textFieldForURL.width

         anchors.left: parent.left
         anchors.right: parent.right
         anchors.bottom: parent.bottom

         contentItem: Rectangle {
            implicitWidth: parent.width
            implicitHeight: parent.height
            radius: width / 2
            color: scrollBar1.pressed ? "white" : "#999999"
         }
      }
   }
}
Computer, Programm, programmieren, Programmiersprache, Qt