Skip to content

Qt 6

This is where all Qt 6 related questions belong

816 Topics 3.9k Posts
QtWS25 Call for Papers
  • how to using the button setenabled when clicked itself?

    Unsolved
    13
    0 Votes
    13 Posts
    483 Views
    W

    @nicker-player

    #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QState> #include <QStateMachine> #include <QFinalState> QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); signals: //this signals may be emit by buttons click, keys events,wheel events, slider move. void sigPageGoStart(); void sigPageGoMid(); void sigPageGoEnd(); void sigPageClose();//this signal emit when close current page,machine will finsh private slots: //Here I only add the button trigger emit state Transition procedure void on_pushButton1_First_clicked(); void on_pushButton_Prev_clicked(); void on_pushButton_Next_clicked(); void on_pushButton_Last_clicked(); void slotPageFinishedState(); private: Ui::MainWindow *ui; QStateMachine* pageStateMachine=new QStateMachine(this); QState* pageStartState=nullptr; QState* pageMiddleState=nullptr; QState* pageEndState=nullptr; QFinalState* pageNoneState=nullptr; void OpenPage(); void ClosePage(); }; #endif // MAINWINDOW_H #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); //1-create state pageStartState=new QState(pageStateMachine); pageStartState->assignProperty(ui->pushButton1_First,"enabled",false); pageStartState->assignProperty(ui->pushButton_Prev,"enabled",false); pageStartState->assignProperty(ui->pushButton_Next,"enabled",true); pageStartState->assignProperty(ui->pushButton_Last,"enabled",true); pageMiddleState=new QState(pageStateMachine); pageMiddleState->assignProperty(ui->pushButton1_First,"enabled",true); pageMiddleState->assignProperty(ui->pushButton_Prev,"enabled",true); pageMiddleState->assignProperty(ui->pushButton_Next,"enabled",true); pageMiddleState->assignProperty(ui->pushButton_Last,"enabled",true); pageEndState=new QState(pageStateMachine); pageEndState->assignProperty(ui->pushButton1_First,"enabled",true); pageEndState->assignProperty(ui->pushButton_Prev,"enabled",true); pageEndState->assignProperty(ui->pushButton_Next,"enabled",false); pageEndState->assignProperty(ui->pushButton_Last,"enabled",false); pageNoneState=new QFinalState(pageStateMachine); connect(pageStateMachine,&QStateMachine::stopped,this,&MainWindow::slotPageFinishedState); //2-add state transition pageStartState->addTransition(this,&MainWindow::sigPageGoMid,pageMiddleState); pageStartState->addTransition(this,&MainWindow::sigPageGoEnd,pageEndState); pageStartState->addTransition(this,&MainWindow::sigPageClose,pageNoneState); pageMiddleState->addTransition(this,&MainWindow::sigPageGoStart,pageStartState); pageMiddleState->addTransition(this,&MainWindow::sigPageGoEnd,pageEndState); pageMiddleState->addTransition(this,&MainWindow::sigPageClose,pageNoneState); pageEndState->addTransition(this,&MainWindow::sigPageGoMid,pageMiddleState); pageEndState->addTransition(this,&MainWindow::sigPageGoStart,pageStartState); pageEndState->addTransition(this,&MainWindow::sigPageClose,pageNoneState); //3- open Page OpenPage(); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton1_First_clicked() { //page move to start page view emit sigPageGoStart(); } void MainWindow::on_pushButton_Prev_clicked() { //page move up //Check page view position, send signal sigPageGoStart\sigPageGoMid\sigPageGoEnd } void MainWindow::on_pushButton_Next_clicked() { //page move down //Check page view position, send signal sigPageGoStart\sigPageGoMid\sigPageGoEnd } void MainWindow::on_pushButton_Last_clicked() { //page move to start page view emit sigPageGoEnd(); } void MainWindow::slotPageFinishedState() { ui->pushButton1_First->setEnabled(false); ui->pushButton_Prev->setEnabled(false); ui->pushButton_Next->setEnabled(false); ui->pushButton_Last->setEnabled(false); } void MainWindow::OpenPage() { //1-open page move to start page view //2-set ui machine pageStateMachine->setInitialState(pageStartState); pageStateMachine->start(); } void MainWindow::ClosePage() { //1-close page //2-stop ui machine emit sigPageClose(); }
  • How setenv before loading the dll file?

    Unsolved
    2
    0 Votes
    2 Posts
    254 Views
    sierdzioS
    start your program through a script (.bat file) which will set up all paths and environment variables if this is about third party libraries, you can load your app first, then set env using qputenv, then load your libs using QLibrary install libraries system-wide so that all apps will have access to them regardless of where they are compile your app statically to include all code inside create a launcher for your app which will set up QProcessEnvironment and then launch your main app through QProcess

    As you can see, there are many ways to solve this. Which solution is correct depends on particular details of your situation and your preference.

  • This topic is deleted!

    Unsolved
    4
    0 Votes
    4 Posts
    146 Views
  • [QtQuick, Multimedia, GStreamer] Can't play video stream

    Solved
    5
    0 Votes
    5 Posts
    772 Views
    0

    Yes, it works!
    For test I send a videotestsrc via console:
    gst-launch-1.0 videotestsrc ! "video/x-raw,width=640,height=480" ! x264enc ! mpegtsmux name=mux ! udpsink host=127.0.0.1 port=8080

    In QML:

    ... MediaPlayer { id: player source: "udp://@127.0.0.1:8080" videoOutput: video } VideoOutput { id: video anchors.fill: parent fillMode: VideoOutput.PreserveAspectCrop } Component.onCompleted: { player.play() }
  • Is there a license difference between qt5 and qt6?

    Solved
    2
    0 Votes
    2 Posts
    997 Views
    SGaistS

    Hi,

    If memory serves well, there has not been any major changes in the licenses. You can see changes related to licences here.

  • qtpaths return incorrect path

    Solved
    2
    0 Votes
    2 Posts
    768 Views
    D

    Dirty hack - create symlink ln --symbolic /usr/lib/qt6/libexec/moc /usr/libexec/moc
    qmake work because it have symlink at /usr

    $ ls -l /usr/bin/qmake* lrwxrwxrwx 1 root root 9 May 3 2019 /usr/bin/qmake -> qtchooser lrwxrwxrwx 1 root root 21 Jun 13 23:13 /usr/bin/qmake6 -> ../lib/qt6/bin/qmake6
  • Qt build crashes

    Unsolved
    3
    0 Votes
    3 Posts
    241 Views
    A

    Add below line in your CMakeLists.txt file :
    find_package(Qt6 REQUIRED COMPONENTS Qml)
    target_link_libraries(${myProject} PRIVATE Qt6::Qml)

    More

  • [Using QPainter in PaintGL() crashes the app]

    Unsolved
    14
    0 Votes
    14 Posts
    766 Views
    JonBJ

    @appdev
    If you have now written a minimal example which shows the problematic behaviour, as @SGaist asked you to, then obviously you should show that code....

  • QT6.3+mysql8.0+Mac

    Unsolved
    3
    0 Votes
    3 Posts
    364 Views
    W

    @JonB thx. I input was wrong.

  • 0 Votes
    19 Posts
    1k Views
    I

    @cristian-adam
    Thank you, I will make further Chan

  • Building QMYSQL / MARIADB with Qt 6.3.0

    Unsolved
    13
    0 Votes
    13 Posts
    2k Views
    SGaistS

    From memory, no, MariaDB is a drop in replacement so it would not make sense to complicate the build system for that.

  • QTABLEWIDGET WITH STYEL

    Unsolved
    8
    0 Votes
    8 Posts
    271 Views
    SGaistS

    Then I would say my suggestion still applies.

  • QQuickWidget as viewport for QMdiArea

    Unsolved
    1
    0 Votes
    1 Posts
    101 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    2
    0 Votes
    2 Posts
    25 Views
  • how to create such tableview?

    Locked Unsolved
    3
    0 Votes
    3 Posts
    200 Views
    SGaistS

    Closing as duplicate

  • [QSpin boxes and strange values]

    Unsolved
    4
    0 Votes
    4 Posts
    241 Views
    JonBJ

    @appdev said in [QSpin boxes and strange values]:

    Why aren't they equal to 0 ?

    Because as I said not all values are exactly representable in a computer double. In fact, to be exact the number which are exactly representable is an infinitely small subset of real numbers!

    Forget about spin boxes for now.

    Show your code which reads the numbers from CSV file.

    Use something like QString QString::number(double n, char format = 'g', int precision = 6) to convert your numbers to strings for displaying/debugging purposes. See what happens if you play with the precision parameter to increase/decrease how many digits are output.

  • 0 Votes
    10 Posts
    2k Views
    Christian EhrlicherC

    @JonB said in Mixing C and C++ in a Qt project. undefined reference to function():

    project(MyProject C CXX)

    This is not needed when you don't need a special language

    project(MyProject)

    is enough - cmake does know how to compile a .c or .cpp file .

  • This topic is deleted!

    Unsolved
    18
    0 Votes
    18 Posts
    29 Views
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    4
    0 Votes
    4 Posts
    7 Views