Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Tags
    3. slots
    Log in to post

    • UNSOLVED How to correctly Connect from qthreadpool
      General and Desktop • signal slots qthreadpool • • PXLFuSSeL  

      11
      0
      Votes
      11
      Posts
      67
      Views

      @SGaist yes, thx, my fault was trying to iterate through the future until not be ready. now i got what i want, not as fast as i want, but it works stable.
    • SOLVED Why does a functor slot must have exactly the same number of arguments as signal?
      General and Desktop • connect slot slots connect slot • • Xeonacid  

      5
      0
      Votes
      5
      Posts
      44
      Views

      @J-Hilk Thanks! Hope it can be fixed soon. @jsulm Same thanks!
    • SOLVED Can you create slots in main.cpp file?
      General and Desktop • thread slots signals connection • • ples76  

      20
      0
      Votes
      20
      Posts
      347
      Views

      @ples76 said in Can you create slots in main.cpp file?: I have solved the problem with all of your help Great, so please don't forget to mark your post as solved! I am trying to find the easiest solution to this since I am under the gun to get this done asap Although you find a solution now, you may want to take into account that having such a main() function is not a good idea as @Christian-Ehrlicher pointed out. So time (and stakeholders) permitting, you might want to look at refactoring your code...
    • SOLVED How do I acces UI components inside a function which I called with a slot function?
      General and Desktop • qt5 gui slots ui object design editor • • Robin_Khn  

      7
      0
      Votes
      7
      Posts
      62
      Views

      @Robin_Khn Ok super. So its just qmake/moc that is a little slow sometimes. So when you add something to the UI from and go back to the code, you can press ctrl+shift+b (build file) it knows the new Widget right away.
    • SOLVED Difficulties connecting signals with slots (static members)
      General and Desktop • static slots signals lua • • SnuggleKat  

      9
      0
      Votes
      9
      Posts
      182
      Views

      @SnuggleKat said in Difficulties connecting signals with slots (static members): Just didn't know signals mustn't be defined... If you mean "implemented" by "defined", then I wrote this in my first reply :) Yes, you dont implement signals. You just set the signal signature in your header file. After that, you can emit your signal to notify connected classes (-> slots)
    • SOLVED Error when connecting a custom class and MainWindow
      General and Desktop • connect slots class signals connect problem • • Forfunckle  

      4
      0
      Votes
      4
      Posts
      101
      Views

      The problem was that my class inherited QGraphicsItem, not QObject, but I found another way to do what I wanted. From now on, I will use the new syntax. Thank you!
    • UNSOLVED How do i acces an other slot?
      General and Desktop • qfile slots timer qtextstream log • • GhostWolf  

      4
      0
      Votes
      4
      Posts
      489
      Views

      I tried some different options, and found a solution: void MainWindow::saveSettings() { name = (QCoreApplication::applicationDirPath() +"/logs/"+ui->lineEdit->text() +".txt"); QFile file (name) ; if (newfile == true){ if (file.exists()){ qDebug ()<<"already exists"; NewLog(); timer->stop(); } else { qDebug()<< "Does not exist"; file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append); QString c_time = QTime::currentTime().toString(); QString sText =QString::number(update) + ". "+ c_time + ": rpm = "+ rpm + ", load = "+ QString::number(load) + ", " + name1+ " = " + result1 + ", "+ name2+ " = " + result2 + ", " + name3+ " = " + result3 + ", "+ name4+ " = " + result4 + ", " + name5+ " = " + result5 + ", "+ name6+ " = " + result6 + ", " + name7+ " = " + result7 + ", "+ name8+ " = " + result8 + ", " + name9+ " = " + result9 + ", "+ name10+ " = " + result10; ui->label_log->setText(sText); update++; QTextStream out(&file); out << sText + "\n"; file.close(); newfile = false; }}else{ file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append); QString c_time = QTime::currentTime().toString(); QString sText =QString::number(update) + ". "+ c_time + ": rpm = "+ rpm + ", load = "+ QString::number(load) + ", " + name1+ " = " + result1 + ", "+ name2+ " = " + result2 + ", " + name3+ " = " + result3 + ", "+ name4+ " = " + result4 + ", " + name5+ " = " + result5 + ", "+ name6+ " = " + result6 + ", " + name7+ " = " + result7 + ", "+ name8+ " = " + result8 + ", " + name9+ " = " + result9 + ", "+ name10+ " = " + result10; ui->label_log->setText(sText); update++; QTextStream out(&file); out << sText + "\n"; file.close(); }} Maybe it can be easier, but i am still learning. Thanks for your input. If you have comments on how to change my code, please tell me. (newlog was only to test something else now)
    • UNSOLVED QT Location Map interaction/slots
      General and Desktop • map slots location • • Citizenfish  

      1
      0
      Votes
      1
      Posts
      160
      Views

      No one has replied

    • SOLVED How to add one parameter to the clicked SIGNAL?
      General and Desktop • signal & slot signal slots array event-handling • • ChristianMontero  

      17
      0
      Votes
      17
      Posts
      12944
      Views

      @ambershark said in How to add one parameter to the clicked SIGNAL?: @aha_1980 That sure does do what he needs, lol. I didn't know about QSignalMapper.. It's funny that even after 16+ years of Qt there's still classes I don't know about. :) I only knew it because I had the same requirement as @ChristianMontero some time ago :)
    • UNSOLVED Qt DoubleSpin Box value changed slot has called twice
      General and Desktop • c++ qt creator qt 5.5 slots debugger • • Sowmiya R  

      22
      0
      Votes
      22
      Posts
      7087
      Views

      @Wael11 For anyone reading this: This is known behaviour, which I stumbled across a long time ago and it was infuriating. With a QSpinbox Qt Internal code uses a timer on clicks/presses. If you step through in debugger you exceed the timeout and get bad/double behaviour. Simplest: change all connect() to QSpinbox click/key to pass Qt::QueuedConnection as last parameter for connection type, not default Qt::DirectConnection. Now you can use debugger breakpoints and all will be well. I wrote a method to connect all my spinboxes like this.
    • SOLVED Pop up a new window on a pushed button
      General and Desktop • button window connect slots • • Adrian.Aioanei  

      6
      0
      Votes
      6
      Posts
      29673
      Views

      Yep, it works. Thanks :)
    • UNSOLVED Qt Creator autocomplete not updating for new UI widgets until (re)compile
      Tools • qtcreator widgets slots autocomplete • • kylenoteboom  

      6
      1
      Votes
      6
      Posts
      2160
      Views

      I was having the same problem, but for me has worked to disable the Clang code model and restarting Qt.
    • UNSOLVED [solved] MetaObject not referencing slots in derived class
      General and Desktop • slots metadata • • XavierLL  

      16
      0
      Votes
      16
      Posts
      2986
      Views

      @kshegunov Yeah, 50% is not Qt enabled so would be an issue. Im just daydreaming :) Hmm, that is actually neat.
    • UNSOLVED Function Requires Output from Multiple Signals?
      General and Desktop • slots signals multiple slots • • soupcan  

      3
      0
      Votes
      3
      Posts
      788
      Views

      Depending on how complex things get, it might make sense to have a "data aggregation layer" between logic and UI. Basically, a UI element would only be connected to a single signal of the aggregation layer, and the aggregation layer would keep track of data changes, and would know when to emit that one signal. It doesn't reduce complexity, but it cleanly distributes it between two parts of your program.
    • SOLVED Error when adding slot to QAction
      General and Desktop • slots qaction • • Suroh6  

      2
      0
      Votes
      2
      Posts
      989
      Views

      @Suroh6 said: I solved it myself, it appears due to my inheritance of the ui_mainwindow i was getting the diamond inheritance issue :) Multiple inheritance from QObject derived classes is not supported, but you shouldn't have that in the first place. Aside from that there's no problem with inheriting from QObject (directly or indirectly) and another class. In fact it's done as a standard way of providing interfaces for plugin implementations.
    • UNSOLVED help with signals and slots
      General and Desktop • slots signals & slots signals • • mar0029  

      7
      0
      Votes
      7
      Posts
      2553
      Views

      @mar0029 As @mrjj already said this is just wrong: MainWindow *test = new MainWindow(this) connect(test->setupScreen, SIGNAL(sendSetupLocation(QString)), this, SLOT(receivedSetupLocation(QString))); You create a NEW instance of MainWindow and connect its signal with the slot. You must use MainWindow instance that already exists. If your dialog is not created directly by MainWindow, but instead by another dialog then you can just pass the pointer to your MainWindow instance to the first dialog constructor which then pass it to the second dialog constructor. Printing the variable which is set in a slot just after connecting the signal to the slot will just print its current value (empty string in this case)., because the slot was not called yet. If you call the slot directly with a not empty string then this string should be printed.
    • SOLVED Trouble with slot execution
      Russian • slots runtime error • • Warbit  

      4
      0
      Votes
      4
      Posts
      1066
      Views

      @Warbit said: oops, its my silly fault. Thanks for help, and sorry for stupid questions. You're welcome :-) Please don't feel bad; I think it was a perfectly valid question. Happy coding!
    • SOLVED QTableWidget Programmatically Select Cells
      General and Desktop • qtablewidget slots signals cell select • • oblivioncth  

      3
      0
      Votes
      3
      Posts
      6084
      Views

      @SGaist Thank you. That seemed to be the last missing piece. It does what I want now.
    • SOLVED [New to QT] Possible to refer to UI objects with dot (.) notation?
      General and Desktop • gui slots class objects • • oblivioncth  

      3
      0
      Votes
      3
      Posts
      1153
      Views

      @JohanSolo Ah ok, so it is due to the organization of C++ not Qt, and like you said, the difference of a class instances and pointers. It has been long time since I've had to use C++ and I never did anything too advance with it other than a text-based adventure game. I generally am more focused on hardware oriented programing such as with C and Verilog, and MATLAB is the only more software (excluding Arduino interaction) oriented language I have decent experience with. Thank you for pointing out why there needs to be a difference. I wasn't familar with pointer usage in C++.
    • UNSOLVED How to connect signals and slots inside QObject subclass?
      QML and Qt Quick • qobject slots signals connect failure • • diredko  

      3
      0
      Votes
      3
      Posts
      1985
      Views

      @diredko Qt will output signal/slot problems on the console. Run your application from the console and you should see something like: QObject::connect: No such slot QObject::movePiece(int, int, int, int) Or something similar if there is an issue. Also you can add a qDebug() << "Got here" to your connect() but like @SGaist said, you are connecting in a bad place. qDebugs() will show up on the console as well. If you are in windows you will have to add CONFIG += console to your project file. Linux and OSX should be fine without. And finally add qDebug() messages to your move and movePiece to see if it's getting in there. Or of course you could use the debugger for all this. ;)
    • SOLVED Q_SLOTS vs slots
      Portuguese • slots macro • • Exotic_Devel  

      2
      0
      Votes
      2
      Posts
      1275
      Views

      @Exotic_Devel said: Q_SLOTS Usar a macro em vez da keyword é recomendada quando você usa outras bibliotecas que podem colidir com o Qt em relação aos signals/slots, que é o caso do Boost.
    • QT no such slot with Q_Object
      General and Desktop • slots • • Hystreal  

      10
      0
      Votes
      10
      Posts
      2666
      Views

      Ok sorry , it works now ! thanks you very much !
    • Scope in QML
      QML and Qt Quick • qml quick slots signals scope signalsslots • • Anas A. Ismail  

      3
      0
      Votes
      3
      Posts
      1255
      Views

      @JKSH Thanks for your help, May you help me more by writing a sample code for this ? Thanks
    • How to notify component when another component isHovered in qml?
      General and Desktop • qml slots signals signals&slots • • Anas A. Ismail  

      1
      0
      Votes
      1
      Posts
      401
      Views

      No one has replied

    • General question about Signals/Slots compared to lamda functor passing
      General and Desktop • slots signals & slots signals lamda functors • • panch  

      5
      0
      Votes
      5
      Posts
      1401
      Views

      @panch said: Would you then restrict the signals/slots to only GUI-related information passing? As a proper way of developing Qt applications, I mean... QNetworkAccessManager emits signals to tell the world that a download has completed. QSerialPort emits signals to tell the world that some data has been received. QMediaPlayer emits signals to tell the world that its playback status has changed. These show that signals and slots are "proper" for developing all kinds of things, not just GUIs.
    • Plugin with signals and slots [SOLVED]
      General and Desktop • plugin signal slots • • dnasta  

      6
      0
      Votes
      6
      Posts
      5650
      Views

      Hello good afternoon, When I go to the forum to solve a problem it is because I could not find anything on the web, but in this case was too simple theme, perhaps only experiencing what he had resolved because it is too simple to implement signals and slots between the application and the dll To end the post: to implement the slot in the plug receiving a signal from the application, add the virtual interface slot public slots: virtual void disparador(QString texto) = 0; and I made in the implementation of the interface public slots: void disparador(QString texto); to connect to the application, I used getObject connect( this, SIGNAL(disparaTexto(QString)), plgItfz->getObject(), SLOT(disparador(QString)) ); Thank you greetings
    • How to inherit QObject based abstract class in two QWidget/QGraphicsScene views
      General and Desktop • model-view qobject slots • • Resurr3ction  

      4
      0
      Votes
      4
      Posts
      2833
      Views

      @JKSH Ah, moc assumes first class only. So its simply not supported. Thats good to know.
    • How to create/edit slot to change a widget's color
      General and Desktop • slots color change • • thestarsatnight  

      1
      0
      Votes
      1
      Posts
      604
      Views

      No one has replied

    • The inferior stopped because it received a signal from the operating system. Signal name : SIGSEGV Signal meaning : Segmentation fault ; Any help please
      General and Desktop • signal slots • • RahulY  

      7
      0
      Votes
      7
      Posts
      5437
      Views

      If you can't, just edit the thread title and prepend [solved]
    • Connecting signals and slots with different parameters: Is it possible?
      General and Desktop • signal & slot signal connect slot slots • • Jorge  

      3
      0
      Votes
      3
      Posts
      4420
      Views

      Hi, Short answer: no The slot signature must either have the same number or less parameters than the signal and the type must be the same.
    • [SOLVED] QAction To Toggle QWidget
      General and Desktop • c++ qt5 slots qstackedwidget toggle • • Adept  

      7
      0
      Votes
      7
      Posts
      1920
      Views

      You could also simplify this a little: void MainWindow::menuToggled() { auto widget = (container->currentWidget() == menuWidget) ? mdiContainer : menuWidget; container->setCurrentwidget(widget); }
    • [SOLVED] Function works, can't add it to slot
      General and Desktop • c++ qt5 slots qt application help • • Adept  

      8
      0
      Votes
      8
      Posts
      2037
      Views

      You can first retrieve the getSelectedTabAsWidget() as a QWidget, check that it's not null, and if qobject_cast<QMdiArea*>() doesn't return NULL. Snippet 1: QWidget* selectedWidget = getSelectedTabAsWidget(); if ( selectedWidget == NULL ) { return; } QMdiArea* mdiArea = qobject_cast<QMdiArea*>(selectedWidget); if ( mdiArea == NULL ) { return; } // Here, we know that mdiArea is indeed a QMdiArea. Snippet 2: QWidget* selectedWidget = getSelectedTabAsWidget(); if ( selectedWidget == NULL ) { return; } if ( ! selectedWidget->inherits(QMdiArea::staticMetaObject.classname()) return; // Here, we know that mdiArea is indeed a QMdiArea. QMdiArea* mdiArea = qobject_cast<QMdiArea*>(selectedWidget);