Navigation

    Qt Forum

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

    • UNSOLVED Allocate memory for a Q_GADGET inside another Q_GADGET
      General and Desktop • qmetaobject pointer qgagdet • • raphasauer  

      2
      0
      Votes
      2
      Posts
      40
      Views

      One more example: #include <QCoreApplication> #include <iostream> #include <QMetaObject> #include "example.h" #include <QDebug> #include <QMetaProperty> #include <QPointer> void gadgetExplorer(void *ptr, const char* s) { //Receives Player and access its meta-object int typeId = QMetaType::type(s); const QMetaObject *mo = QMetaType::metaObjectForType(typeId); qInfo() << "Q_GADGET: " << mo->className(); QMetaProperty mp; for(int i = 1; i < mo->propertyCount(); i++) { mp = mo->property(i); qInfo() << "Q_PROPERTY: " << mp.typeName() << "Value: " << mp.readOnGadget(ptr); if(int(mp.type()) == 1024) gadgetExplorer(ptr, mp.typeName()); } } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); qRegisterMetaType<Player>(); qRegisterMetaType<P2D>(); qRegisterMetaType<P2D*>(); Player p1; p1.setSpeed(30); p1.p2d = new P2D(); p1.p2d->setX(10.0); p1.p2d->setY(25.0); gadgetExplorer(&p1, "Player"); return a.exec(); } gadgetExplorer() works fine for the first Q_GADGET, but for the second one the read property doesn't work. Is it possible to access the second's Q_GADGET pointer?
    • SOLVED Pointer to a Q_GADGET
      General and Desktop • qobject function pointer meta-objects qgagdet • • raphasauer  

      3
      0
      Votes
      3
      Posts
      109
      Views

      @VRonin Solved! Thanks for your time!
    • SOLVED Check if a pointer was deleted in Qt for GUI Application
      General and Desktop • delete pointer • • SpaceToon  

      7
      0
      Votes
      7
      Posts
      949
      Views

      @SpaceToon said in Check if a pointer was deleted in Qt for GUI Application: Thank you very much, that worked! Do you mean just replacing delete with deleteLater()? It would be discoveryAgent->deleteLater(); Check out the documentation under the given link in my post.
    • SOLVED Project crashes when closing Mainwindow
      General and Desktop • pointer crashing dynamic allocat • • Another Qt Beginner  

      5
      0
      Votes
      5
      Posts
      441
      Views

      Which one do you mean ?
    • UNSOLVED Application crashes while accessing Pointers and while Hovering over custom QGraphicsItems
      General and Desktop • c++ qgraphicsitem segfault pointer • • Lanparty  

      14
      0
      Votes
      14
      Posts
      1592
      Views

      @Lanparty said in Application crashes while accessing Pointers and while Hovering over custom QGraphicsItems: btw: how do I change the status of my post to "solved"? First post, Topic Tools button to the side.
    • SOLVED std::unique_ptr with QObject derived class?
      General and Desktop • c++ qobject pointer uniqueptr copy-constructo • • oblivioncth  

      5
      0
      Votes
      5
      Posts
      1903
      Views

      @oblivioncth said in std::unique_ptr with QObject derived class?: Won't let me mark your post as the answer for some reason. Sorry. Done for you :)
    • SOLVED How to get a class pointer without messing up data.
      General and Desktop • class pointer inheritance pointers • • Basti46  

      4
      0
      Votes
      4
      Posts
      1120
      Views

      Hi Just a note first Having class SerialPort : public QObject and then QSerialPort *serialPort; Where only diffence is capital S to the main class is just confusing. anyway, why is the issue with settings(new SettingsDialog()), did you declare it as void settings(SettingsDialog *mydialog) Im not sure what you dont understand. To use a pointer to a class in another class, you simply give the pointer to the other class and it can use it class B {}; class A { B* mykeptBpointer; setB(B* myb) { mykeptBpointer = myb; } void DoB { mykeptBpointer->xxxx(); }; A mya; B* myb = new B; mya.setB(b); oh, is settings(new SettingsDialog()) rather settings = new SettingsDialog();
    • SOLVED QList<QObject*> and Memory Leak Issue
      General and Desktop • qobject qlist memory leak pointer • • Dong  

      15
      0
      Votes
      15
      Posts
      12315
      Views

      @kshegunov There is a reason why I can't use QT Property Binding (It only support predefined Property using Q_PROPERTY script). Please take a look at my topic about Auto Binding 2 ways with Dynamic Property But Binding is an other topic. About "Object's pointers & Memory" I also take an advise from a Pro in C++ & memory management. His solution is implement a Factory Pattern to Create/Delete Object's pointers (also free memory when an instance had no pointer to it.) (I think I'll give it a try)
    • UNSOLVED Qt send pointer to window as reference to not create another window
      General and Desktop • qtablewidget mainwindow pointer • • Mr Question  

      4
      0
      Votes
      4
      Posts
      1253
      Views

      Mayby try using Qt's signal slot system: //A->reciver //B->sender //B signals: void B::newData_ready(QString data); //you have to pass apropriate type, assuming QString since it is from QLineEdit slots: void B::on_SendButton_clicked() { emit newData_ready(userData_LineEdit->text()); } //A slots: void A::on_newData_ready(QString data) { QTableWidgetItem *item = new QTableWidgetItem(data); //here add item where u want } connect(B, SIGNAL(newData_ready(QString)), A, SLOT(on_newData_ready(QString))); Just a scheme so it probably wont work like that but I hope you get the point.
    • SOLVED QThread and pointers
      General and Desktop • qthread pointer • • beecksche  

      12
      0
      Votes
      12
      Posts
      3920
      Views

      @beecksche said: The advatage of a QScopedPointer is that you don't have to care about the destruction of the object, right? Yes. It's a thin wrapper around the raw pointer and will delete the held reference when it goes out of scope. The idea is to use the stack based QScopedPointer object to manage the heap-allocated object it's referencing. Kind regards.
    • SOLVED Compose pointer to property of object
      General and Desktop • c++ properties pointer objects • • McLion  

      25
      0
      Votes
      25
      Posts
      5496
      Views

      Got it solved :-) QWebFrame * webGUIframe = qobject_cast<QWebFrame >(sender()); QWebView * webGUI = (QWebView)(webGUIframe->parent())->parent(); webGUI->page()->mainFrame()->addToJavaScriptWindowObject("NativeBridge", this);
    • UNSOLVED Can't compile when using a pointer parameter in a signal/slot
      General and Desktop • signal & slot pointer • • kitfox  

      6
      0
      Votes
      6
      Posts
      3029
      Views

      @kitfox Figured it out. The Q_PROPERTY in Enviroment had the wrong data type.
    • Memory Management
      General and Desktop • memory pointer reference smart pointers management • • LauraB  

      4
      0
      Votes
      4
      Posts
      2496
      Views

      Hello, Both inputs are highly appreciated. I understand better how, when and why should I choose pointers over refs. I'm still reading some stuff here and there on how to produce some good code. Memory management has always been a doozy matter in C++ and i just can't get this Stroustrup quote out of my head : "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off. ". Thanks again for replying so quickly, I will apply everything i've learned here on my work asap. Best regards.
    • Can somone help explain some fundementals of c++? I keep seeing this stuff over and over and just want that "push" to help me understand.
      General and Desktop • c++ pointer const referance • • Rample  

      4
      0
      Votes
      4
      Posts
      1386
      Views

      Why parent ptr? Parent child relationship - http://doc.qt.io/qt-5/objecttrees.html
    • [SOLVED] QImage using pointer to valarray ?
      General and Desktop • qimage pointer valarray • • CamelFrog  

      6
      0
      Votes
      6
      Posts
      1839
      Views

      @SGaist Ok, I just tried to rescaled my image array within an intensity between 0 to 255 and cast a uchar*, it's working now. Thanks
    • Memory management with QObjects
      General and Desktop • qobject memory pointer inheritance • • RDiGuida  

      4
      0
      Votes
      4
      Posts
      1618
      Views

      If your question was how to initialize QObject from child you do not need extra Parent variable, no extra deletes, just add it in constructor: Contact::Contact(int cat,QString fir,QString lst,QString ad,QString zp, QString ct,QString nm,QObject *parent) ::QObject( parent ) { .......... }