Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.5k Topics 457.3k Posts
  • Replicating double borders with QSS

    Solved qss stylesheet
    5
    0 Votes
    5 Posts
    2k Views
    SGaistS
    You can read the class sources.
  • How to solve Error: The QMediaPlayer object does not have a valid service on Windows.

    Unsolved
    3
    0 Votes
    3 Posts
    436 Views
    W
    @eyllanesc it's Qt 5.11.2
  • GameLoop parameter

    Solved
    7
    0 Votes
    7 Posts
    689 Views
    J
    Thanks a lot!! It is finally working! Wooohoo! Thank you for your patience, I know those may be basic stuff, but I am just a beginner.
  • PyQT, how to use QThread to stop application from proceeding?

    Unsolved
    4
    0 Votes
    4 Posts
    3k Views
    JonBJ
    @freemanl144 If you really have long running, non-UI processing to do go ahead and use threads and don't get it wrong. Doesn't alter the fact that threads cannot address the UI. Use signals from your threads to inform the UI thread of something for it to act on. Use a signal from your main thread to secondary threads if you want to tell them to exit. If the UI needs to allow the user to interrupt, put up a dialog and send a signal to the sub-threads (preferably) or terminate them (not so preferably).
  • Is this concept wrong / doable ?

    Unsolved
    8
    0 Votes
    8 Posts
    534 Views
    artwawA
    @AnneRanch "studio" here refers to the "design studio" program. It's (I think) outside the scope of our talk here. I was referring to the situation where you create widgets via c++. They will not be visible in the Creator but you can connect their signals and slots. Consider this example (submenu with zoom levels): zoomMenu = viewMenu->addMenu(tr("&Zoom level")); zoomLevels = new QActionGroup(this); for (auto x=10;x<210;x=x+10) { QAction *act = new QAction(QString::number(x)+"%",this); act->setCheckable(true); zoomLevels->addAction(act); connect(act,&QAction::triggered,this,[=](){setZoom(act->text());}); } zoomMenu->addActions(zoomLevels->actions()); Each action is connected (here via lambda). With widget (same boilerplate application, QComboBox for zoom level): zLevel = new QComboBox(this); for (auto x=0;x<zoomLevels->actions().size();++x) { zLevel->addItem(zoomLevels->actions().at(x)->text()); } zLevel->addItem(tr("Fit to window")); connect(zLevel,&QComboBox::currentTextChanged,this,&MainWindow::setZoom); ui->toolBar->addWidget(zLevel); There is absolutely no need to use Creator for connecting signals and slot. I, personally, consider this a bad habit, as connections are not clearly visible in the code.
  • This topic is deleted!

    Solved
    7
    1 Votes
    7 Posts
    817 Views
  • 0 Votes
    2 Posts
    1k Views
    VRoninV
    @LRDPRDX said in In what thread would a QObject be deleted if it was moved to another QThread?: the dtor must be called and executed in the secondary thread not the main one. Am I right? Correct, that's what connect(thread, &QThread::finished, worker, &QObject::deleteLater); does and as you noted> No more events will be processed in the thread, except for deferred deletion events. Do the deleteLater will still picked up after the finished is emitted and the destructor will run in the secondary thread
  • Debugging starts, Debugging finished.When I starting debugging of startup project

    Unsolved
    2
    0 Votes
    2 Posts
    600 Views
    JonBJ
    @amu1550 This just means your program successfully ran from beginning to end. If you expected it to do anything, show what code you have written that would result in something happening.
  • How to stop QThread?

    Unsolved
    18
    0 Votes
    18 Posts
    4k Views
    KroMignonK
    @qwe3 said in How to stop QThread?: I change a little your code ( I never before used QFuture etc. so maybe I do something wrong ): runnable->run(); after futureWatcherProgress.setFuture(runnable->getFuture()); Okay, my code was o a little bit too rough, so I will be more explicit: a create a class based on QRunnable to be able to use it with QThreadPool. in the method getFuture(), the class instance is transformed to future a will run in next thread available the thread pool. So the run() method will be called a soon as possible after that I record the QFuture instance returned into the QFutureWatcher instance to be aware about state changes. Your fun1() don't made sense; the QFutureWatcher is a local variable which will be delete at function end! Change it like this: void MainWindow::fun1() { // do NOT use a local variable!!! auto futureWatcherProgress = new QFutureWatcher<void>(); // ==> delete QFuteWatcher instance instance when process done connect(futureWatcherProgress, &QFutureWatcher<void>::finished, futureWatcherProgress, [futureWatcherProgress]() { futureWatcherProgress->deleteLater(); qDebug() << "Processing done."; }); // ==> stop future on application exit connect(qApp, &QCoreApplication::aboutToQuit, futureWatcherProgress, &QFutureWatcher<void>::cancel); // follow progression connect(futureWatcherProgress, &QFutureWatcher<void>::progressValueChanged, this, [](int progressValue){ qDebug() << "Progression is" << progressValue; }); connect(futureWatcherProgress, &QFutureWatcher<void>::progressRangeChanged, this, [](int minimum, int maximum){ qDebug()<< "Progression range from" << minimum << "to" << maximum; }); connect(&futureWatcherProgress, &QFutureWatcher<void>::progressTextChanged, qApp, [](const QString &progressText) { qDebug() << "Progression:" << progressText; }); // create worker ==> QRunnable are automatically destroyed when finished (cf QRunnable::autoDelete()) auto runnable = new Work(); // register future and start processing futureWatcherProgress->setFuture(runnable->getFuture()); }
  • Path replacement in Qt3D

    Unsolved
    1
    0 Votes
    1 Posts
    122 Views
    No one has replied
  • QButtonGroup signals

    Solved
    10
    0 Votes
    10 Posts
    776 Views
    SPlattenS
    @J-Hilk , yes, if you know where to look but it isn't very clear on the signals page, unless you scroll down.
  • How to put dynamic library project in one project

    Solved
    10
    0 Votes
    10 Posts
    901 Views
    jsulmJ
    @IknowQT said in How to put dynamic library project in one project: I want to exclude files from being created Then do so. What is the problem?
  • QLibrary not working

    Solved
    5
    0 Votes
    5 Posts
    415 Views
    I
    @jsulm There is something wrong with creating a dynamic library. extern "C" MYFIRST_LIB_EXPORT void TEST_FUNC_LIB_For() MYFIRST_LIB_EXPORT I added this and it worked fine.
  • QTabWidget : how to get widget ui made with designer

    Unsolved
    12
    0 Votes
    12 Posts
    1k Views
    S
    I guess there are two different ways of combining the widgets inside the QTabWidget. Let's get it sorted out, which you are using. Nevertheless, for both ways there have been the correct answers already. You just have a single ui file for everything. I.e. in your ui file you have the QTabWidget, but also the subwidgets. In this case, as already mentioned, you can just access the buttons, etc. directly through ui->objectName. You have one ui file for the QTabWidget and one ui file for each subwidget. Somehow (I have never tried that) inside the Designer you put the ui files of the subwidgets into the QTabWidget. @jsulm already suggested that you connect the signal of the button to the widget itself. There is a way directly inside the designer to do just that. So, inside the ui file of the subwidget you do all the connections and have a bunch of new signals in your subwidget. You'll be able to access these from your C++ code then.
  • stack widget in qt designer not resizing

    Solved
    5
    0 Votes
    5 Posts
    3k Views
    Puppy BearP
    @Bonnie Thanks! IT Exactly worked
  • "QNmeaPositionInfoSource: cannot find NMEA sentence with valid date & time".

    Unsolved
    3
    0 Votes
    3 Posts
    267 Views
    6thC6
    @Renjith-R https://doc.qt.io/qt-5/qnmeapositioninfosource.html#setDevice The source device can only be set once and must be set before calling startUpdates() or requestUpdate(). Note: The device must emit QIODevice::readyRead() for the source to be notified when data is available for reading. QNmeaPositionInfoSource does not assume the ownership of the device, and hence does not deallocate it upon destruction. /* logfile */ You just yadda yadda'd the most important detail. Example project probably will help: https://doc.qt.io/qt-5/qtpositioning-logfilepositionsource-example.html
  • How to change swap intervals for QGLWidget

    Unsolved
    7
    0 Votes
    7 Posts
    694 Views
    S
    @SGaist This same issue exists with the version 6.2.
  • How to get to Completer Popup on Down Arrow

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

    Unsolved
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • SOLVED What signal to react on when QTabWidget is first displayed?

    Unsolved
    11
    0 Votes
    11 Posts
    788 Views
    A
    @JoeCFD said in What signal to react on when QTabWidget is first displayed?: override the following func. protected: void showEvent(QShowEvent *) override; inside this func, you can query current tab index. Maybe I can modify this to solve my other issue. Thanks