Questions tagged [qpointer]

QPointer is a Qt class which provides guarded pointers to QObject.

QPointer is a template class which provides quarded pointers to QObject.

Guarded pointer QPointer<T> is like normal pointer T* except it is automatically set to 0 when referenced object is destroyed. T must be subclass of QObject.

Official documentation can be found here for Qt 4.8 and here for Qt 5.

24 questions
1
vote
2 answers

Should I delete QPointer in the destructor of the class?

Suppose I have a class like the following: #include #include class MyClass: public QObject { private: QPointer m_process{ nullptr }; public: MyClass(QObject *parent = nullptr) : QObject{ parent } …
Const
  • 1,306
  • 1
  • 10
  • 26
1
vote
1 answer

QPointer to MainWindow

I'm creating a dialog window and want to know, how to pass a pointer to MainWindow to it ? Say, I need to access a getter method from MainWindow in my dialog. MainWindow declaration is straight from the wizard: class MainWindow : public…
Dennis S
  • 315
  • 3
  • 13
1
vote
1 answer

QPointer for accessing object methods

have a strange problem using QPointer for accessing object method from a different, not related, object. I've prepared a little example to explain it better. I created two QWidget, Widget_A and Widget_B in a simple QDialog. I need to access from…
bullet
  • 83
  • 7
0
votes
1 answer

Connect Signal and Slots with QPointer

I am creating a GUI application in which I have a dynamic QComboBox. I have used QPointer to store the QComboBox * such that I can avoid a dangling pointer when it is deleted (elsewhere). Even though QPointer is supposed to be a smart pointer with…
Abhi
  • 81
  • 7
0
votes
1 answer

Sorting vector of QPointers

I have: std::vector< QPointer > items; and the call to sort: std::sort(items.begin(), items.end(), custComparFunction) I am using the custom sorting function: bool ToDoList::custComparFunc(QPointer i1, QPointer i2){ …
user2145312
  • 896
  • 3
  • 10
  • 33
0
votes
1 answer

Using QPointer and QObject::connect with C++11

I'm using Qt 5.4 and trying to resume accepting new connections when the "disconnected" signal from my QTcpSocket is emitted. So I wrote the following in .h and .cpp file respectively: QPointer tcpServer; // in .h…
Reza
  • 3,473
  • 4
  • 35
  • 54
0
votes
1 answer

Finding a child member that is a QPointer

I am trying to use findChildren to pull a list of parameters from my program. The code is below: QList > theFullParameterList; foreach(TParameter *child, this->findChildren()) { theFullParameterList <<…
SGEng
  • 1
0
votes
1 answer

Can I use QScriptEngine.toScriptValue with a QPointer to a QObject?

The documentation on working with QtScript and converting back and forth between script values and C++ mentions that you can use QScriptEngine.toScriptValue with a QObject* type and have it work automatically, casting the object and returning a…
akbiggs
  • 34,001
  • 6
  • 25
  • 36
0
votes
1 answer

QPointer to QHash

Is it possible to use QPointer with QHash? QPointer> > pHash;
user635818
  • 99
  • 2
  • 9
1
2