Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.4k Posts
  • QtMultimedia Cmake

    Solved
    5
    0 Votes
    5 Posts
    2k Views
    jsulmJ
    @AliM93 When you call cmake. If you use QtCreator you should be able to set such variables.
  • QStateMachine, detect unhandled signals/ transitions

    Unsolved
    6
    0 Votes
    6 Posts
    649 Views
    P
    Hi, thanks for the reply, here's some code to demonstrate the issue. Note, I expected the debug output from the eventTest() routine to get output when the signal fires but it doesn't. If I change the initial state I can get it to work, presumably because this determines which transitions are active. I believe I could achieve what I want by using a parent state and registering transitions on that, for every signal, but I was hoping there's a more elegant solution? Thanks " /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** BSD License Usage ** Alternatively, you may use this file under the terms of the BSD license ** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include <QtCore> #include <stdio.h> #include <QStateMachine> #include <QThread> class QStatePlus: public QState { public: QStatePlus(QString name, QState *parent = 0) : QState(parent),m_name(name){} virtual void onEntry(QEvent *event) override {qDebug () << "Entering state " << m_name;} QElapsedTimer t; QString m_name; }; class QTransitionPlus : public QSignalTransition { public: template <typename PMF> QTransitionPlus( const typename QtPrivate::FunctionPointer<PMF>::Object obj, PMF signal, const QString& name) : QSignalTransition(obj, signal), m_name(name){} protected: bool eventTest(QEvent e) { if (!QSignalTransition::eventTest(e)) { if(e->type() == QEvent::StateMachineSignal) { QString statename; QStatePlus qsp = dynamic_cast<QStatePlus>(this->sourceState()); if(qsp) { statename = qsp->m_name; } qDebug () << "XXX unhandled signal in state: " << statename << " " << "in transition" << m_name; } return false; } return true; } private: QString m_name; }; class QStateMachinePlus: public QStateMachine { Q_OBJECT public: QStateMachinePlus(QObject *parent = 0) : QStateMachine(parent){} // virtual bool event(QEvent *e) override {qDebug () << "XXX MACHINE event address " << QState::event(e); qDebug () << "accepted " << e->isAccepted(); return true; } void emitTest1To2(){qDebug() << "emit 1to2"; emit sig1To2();} void emitTest2To3(){qDebug() << "emit 2to3"; emit sig2To3();} void emitTest3To1(){qDebug() << "emit 3to1"; emit sig3To1();} signals: void sig1To2(); void sig2To3(); void sig3To1(); void test(); public slots: void handlesig2To3(){/qDebug() << "Got handlesig2To3";/} void handlesig1To2(){/qDebug() << "Got handlesig1To2";/} }; //! [3] int main(int argc, char argv) { QTimer t1; QTimer t2; QCoreApplication app(argc, argv); QStateMachinePlus machine; QStatePlus s1 = new QStatePlus("s1"); QStatePlus s2 = new QStatePlus("s2"); QStatePlus* s3 = new QStatePlus("s3"); machine.addState(s1); machine.addState(s2); machine.addState(s3); machine.setInitialState(s2); QTransitionPlus* trans1To2 = new QTransitionPlus(&machine, &QStateMachinePlus::sig1To2, "1 to 2"); trans1To2->setTargetState(s2); QTransitionPlus* trans2To3 = new QTransitionPlus(&machine, &QStateMachinePlus::sig2To3, "2 to 3"); trans2To3->setTargetState(s3); QTransitionPlus* trans3To1 = new QTransitionPlus(&machine, &QStateMachinePlus::sig3To1, "3 to 1"); trans3To1 ->setTargetState(s1); s1->addTransition(trans1To2); s2->addTransition(trans2To3); s3->addTransition(trans3To1); machine.start(); qDebug() <<"Start test"; t1.setInterval(5000); QObject::connect(&t1, &QTimer::timeout, &machine, &QStateMachinePlus::emitTest1To2); //t1.setSingleShot(true); t1.start(); // t2.setInterval(1000); // t2.setSingleShot(true); // QObject::connect(&t2, &QTimer::timeout, &machine, &QStateMachinePlus::emitTest1To2); // t2.start(); return app.exec(); } //! [6] #include "main.moc" "
  • How can i get a index of a treeview ?

    Unsolved
    5
    0 Votes
    5 Posts
    382 Views
    mrjjM
    @developer_96 said in How can i get a index of a treeview ?: Do you know how to count to the next index in the qtree view ? Well you can use https://doc.qt.io/qt-5/qtreeview.html#indexAbove https://doc.qt.io/qt-5/qtreeview.html#indexBelow
  • QTextEdit, how to insert multiple lines?

    Unsolved
    9
    0 Votes
    9 Posts
    3k Views
    Ketan__Patel__0011K
    Use Append Function for It QTextEdit::append("Your String");
  • Draw a point when button is clicked

    Unsolved
    7
    0 Votes
    7 Posts
    861 Views
    Pl45m4P
    @mitrovicl said in Draw a point when button is clicked: QPushButton *button = QMainWindow::findChild<QPushButton *>("pushButton"); I assume you have a mainWindow.ui (modified with QtDesigner), then this is not necessary. Just access you button by using your ui pointer. ui->pushButton connect(button, SIGNAL(released()), SLOT(onClick())); and better use the updated, Qt5 function-based "Signal & Slot"-syntax. connect(ui->pushButton, &QPushButton::released, this, &MainWindow::onClick); https://wiki.qt.io/New_Signal_Slot_Syntax
  • QListWidget which signal?

    Solved
    12
    0 Votes
    12 Posts
    891 Views
    SPlattenS
    What can I say I'm doing lots of things at the same time, so I missed something, not the end of the world.
  • Using setData(Qt::EditRole, xxx) with QTableWidgetItem

    Solved
    19
    0 Votes
    19 Posts
    11k Views
    T
    It turns out to be a very good method which I seeks for a really long time. But now I use Qt 6.0.0, so the last return statement does not work well. So it needs to be changed into: return QItemEditorFactory::createEditor(userType, parent); And it is done!
  • Dont want QDockWidget Resize

    Unsolved
    1
    0 Votes
    1 Posts
    104 Views
    No one has replied
  • QT Progress bar in console application - C++

    Unsolved
    6
    0 Votes
    6 Posts
    720 Views
    J.HilkJ
    @Nanda1605 QWidgets and QML do have different styles. I'm not sure if you can simply change the style of the QML progress bar to fit the QWidget one. BUT, nothing is stopping you from customizing your QML progress bar to your liking https://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-progressbar
  • Setting a translucent background to current widget of QStackedWidget

    Unsolved
    3
    0 Votes
    3 Posts
    471 Views
    B
    @walle19 Yes your approach is wrong. You shouldn't define the spinner as a page because in QStackedWidget when you switch to one page, others will be hidden. Even the background is translucent you still won't see other pages. Just create it as a child widget of QStackedWidget (or any parent widget) and control the geometry and visibility yourself. And another thing to mention, will your processing() function block the main thread? If it will then the spinner may be not shown properly.
  • Move the joystick according to serial data

    Unsolved
    2
    0 Votes
    2 Posts
    181 Views
    Kent-DorfmanK
    joysticks are input devices. they generate input data. they don't receive it.
  • Infinite condition checking

    Solved
    17
    0 Votes
    17 Posts
    1k Views
    SGaistS
    Order of destruction, code run during destruction, etc Think of a database, you likely appreciate the fact that all operations are finalised before it stops so you don't have corrupted data when you restart it.
  • [SOLVED] Use QScollArea & QLabel to display image

    18
    0 Votes
    18 Posts
    6k Views
    SGaistS
    @phnhung98 said in [SOLVED] Use QScollArea & QLabel to display image: Hi, I followed your link but it is not available. I am interested in how you solved the problem. I am also trying to display video stream on QLabel with high framerate and large size of image. However, I suffer from screen tearing effect. Thanks. Hi and welcome to devnet, Please define high speed and large size.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • Customize QTAbBar

    Unsolved
    4
    0 Votes
    4 Posts
    675 Views
    mrjjM
    @24unix Hi Ok. np. Basically, we just use setTabButton to place a Widget on top of the tab that has 1 ToolButton for close and one label for Text and a label to show the icon. All in a layout to keep them where we want them.
  • QThread::Priority for QThreadPool or QRunnable?

    Unsolved
    10
    0 Votes
    10 Posts
    2k Views
    CJhaC
    @ollarch Thanks, yes this makes sense, I will try it.
  • Is it possible to make the size of a text in a QStatusBox bigger?

    Unsolved
    2
    0 Votes
    2 Posts
    162 Views
    raven-worxR
    @developer_96 statusBar->setFont(...)
  • Read Data From URL

    Solved
    20
    0 Votes
    20 Posts
    2k Views
    jsulmJ
    @Ketan__Patel__0011 said in Read Data From URL: But My Library Is Qt Based That is clear. But without Qt event loop Qt networking isn't going to work. You could execute networking part (from your DLL) in a thread with Qt event loop.
  • Any stylesheet for clear button of qlineedit?

    Unsolved
    3
    0 Votes
    3 Posts
    907 Views
    JonBJ
    @JoeCFD Unless you find better: I do not see from published docs that you can affect the inbuilt "clear" button from stylesheet. Only if you replaced it with your own icon in code can you alter it.
  • I want to show a variable in the QStatusBar after calling a funtion

    Unsolved
    4
    0 Votes
    4 Posts
    251 Views
    jsulmJ
    @developer_96 Like documented https://doc.qt.io/qt-5/qstring.html#arg