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
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, Scrollbar