Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.5k Posts
  • Some Question regarding Pointers and Destructors and safety...

    5
    0 Votes
    5 Posts
    4k Views
    J
    Hi Satmosc, What I meant by that was.. @ #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; delete m_testWidget; } void MainWindow::on_showButton_clicked() { m_testWidget = new QWidget(); m_testWidget->setAttribute(Qt::WA_DeleteOnClose); m_testWidget->show(); } @ In the above example, when we click the button a new window is shown, and as you can see, the window is created without a parent. The code would give a segfault in trying to delete the m_testWidget twice. When we close the window manually, it's deleted, but we are also deleting it in our destructor, so, it causes a crash. Of course, if you have a parent for a widget, then it is not a window by default, but can be made into one using the setWindowFlags(Qt::Window) as you have pointed out. I'm not able to replicate a case where the Qt::WA_DeleteOnClose conflicts with Qt's automatic destruction of objects using the parent/child. But what I meant about the main() function is: Don't do this: @ #include <QtGui/QApplication> #include "mainwindow.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.setAttribute(Qt::WA_DeleteOnClose); w.show(); return a.exec&#40;&#41;; } @ Because, in this case, we would get a seg fault at the end of execution, because the main window is deleted on close, and at the end of main() which returns after the close of the main window, the variable "w" allocated on the stack will be tried to be removed causing multiple deletions. If I find some more relevant documentation, I will add it to this thread. [EDIT: Thank you Volker for the additional info. As mentioned above, you can use both the automatic memory management using parent/child and Qt::WA_DeleteOnClose together safely. So this is okay.. @ #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_showButton_clicked() { m_testWidget = new QWidget(this); m_testWidget->setWindowFlags(Qt::Window); m_testWidget->setAttribute(Qt::WA_DeleteOnClose); m_testWidget->show(); } @ )
  • Possible to capture all the tcp packages sent from my computer?

    3
    0 Votes
    3 Posts
    2k Views
    S
    For this you should take a look at the pcap lib and use Qt as frontend.
  • [SOLVED] [N00b] Access and usage of PostgreSQL functions in a Qt GUI

    13
    0 Votes
    13 Posts
    7k Views
    S
    I recently created a SQLITE database with a simple Qt interface, resorting to using raw SQL only for the CREATE TABLE statements when initializing an empty db. I used Qt classes for everything else, as this application is to take data from a giant POSTGRESQL db on the web and store some of it locally in SQLITE. I .append() then .setValue() QSqlFields to QSqlRecords that I .insertRecord() into QSqlTableModels which I had bound with .setModel() to my QTableViews. I had also done this whole project using .prepare() and .exec() of QSqlQueries. This way was a little less typing, and a little quicker to code. The simple SQL that I used could have been tailored for POSTGRESQL, which SQLITE would have converted internally (data types in particular), so it could be "cross db." I did the all SQL to all QSql-model comparison strictly to judge performance. There was simply no discernable difference in performance of the db actions when the app was being developed with a half-million records and the SQLITE .filename() was set to ":memory:". Disk access was the bottleneck in the final creation of the complete db. In the end- I prefered the QSql-classes all the way, especially for binding to my QModelViews and letting it negotiate the lazy population of views in my 16 million record db.
  • Stylesheet for qcombobox

    4
    0 Votes
    4 Posts
    8k Views
    L
    OK, you're right sorry about that, I thought the editable was for the lineedit (instead of just indicating whether it is present or not). I didn't find a way to access the QLineEdit directly from within the stylesheet, but you have two alternatives: Set the background for the entire QComboBox and set it back for QComboBox::drop-down Use the lineEdit() function to access the lineedit and set the stylesheet directly Hope that helps and sorry I lead you the wrong way at first
  • When will Qt support indicators?

    10
    0 Votes
    10 Posts
    5k Views
    T
    From what I understand the patch have some issues which need to be figured out before we can put it into Qt 4.8. This does not imply that the code is of minor quality or anything negative, just that some polish is required to make it work better on one platform or another, improve the APIs a bit, etc. A biggish contribution has to go through the legal department, too. All that takes a while. Having said all that: We have high hopes to improve the process of getting contributions into our code with the open governance process. Unfortunately I am not up to date with when that will finally become available, even though Qt Creator is doing a pilot of the process for a couple of weeks already. We can not wait to finally see the new process in the wild! Till the patch ends up in 4.8: Just use the Qt that your distributor has conveniently patched for you in your ubuntu version of choice. If you need a custom Qt, then just add the patch yourself and off you go:-) The sources are all there, you do not need to wait for us:-)
  • String from sign

    10
    0 Votes
    10 Posts
    3k Views
    R
    Thank you, this is that I was searching
  • Process stays in memory after application closes

    11
    0 Votes
    11 Posts
    9k Views
    G
    [quote author="umen242" date="1307707592"]Volker , your code doesn't work for me , only the thing with timer how can i debug signal/slot to see what is wrong ?[/quote] Then your last window isn't closed. Maybe you just hide() it...
  • [Moved] determing subclass of QGraphicsItem

    12
    0 Votes
    12 Posts
    5k Views
    D
    Hi, I have Holiday and found some time to try out your advice. It works fine with enum type. @ enum { ShieldType = QGraphicsItem::UserType + 1, BulletType }; @ thanks for your support. Kind regards, David DC
  • PNG compression method 0

    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • [SOLVED] QGraphicsBlurEffect messing up with performances

    6
    0 Votes
    6 Posts
    3k Views
    E
    That's right, I couldn't figure how to edit the title...! thanks
  • Is it feasable to copy a Qt class into my project and build it in there

    5
    0 Votes
    5 Posts
    2k Views
    Y
    Too many dependencies to do this.
  • Poppler for Windows using MSVC 2010

    4
    0 Votes
    4 Posts
    5k Views
    Z
    I resolved my problem with acrobat reader ActiveX control: added QAxWidget to window and with dynamicCall("LoadFile(const QString&)", pdfPath) I'm displaying pdfs; Thanks all
  • Drawing QWidget in QPixelBuffer

    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • Closing QMdiSubWindow From Within Widget

    4
    0 Votes
    4 Posts
    4k Views
    G
    It's in the docs of "QMdiArea::addSubWindow() ":http://doc.qt.nokia.com/4.7/qmdiarea.html#addSubWindow
  • 0 Votes
    3 Posts
    3k Views
    K
    Thank you. If this behavior is not wanted (as in my case) you can circumvent it by removing and reparenting the children. Example below @ QList<QGraphicsItem *> childItemList = itemToBeAdded->childItems(); foreach (QGraphicsItem *child, childItemList) child->setParent(0); someGroup->addToGroup(itemToBeAdded); foreach (QGraphicsItem *child, childItemList) child->setParent(itemToBeAdded); @
  • Async TCP server design

    6
    0 Votes
    6 Posts
    7k Views
    K
    What other chances do you have then? I am using pointers to sockets stored in the containers. you might implement different containers for different information/subscription types. You probably may have the socket pointers in different containers. However, the different containers would make only sense when your subscription checking very expensive. this should be handled by the socket. I would assume that there is some buffering going on. is no problem. As stated I am removing the socket from my container when the transmission has a problem.
  • QDateTimeEdit - setDateTime() doesn't work [Value from Database]

    11
    0 Votes
    11 Posts
    9k Views
    G
    I suggest storing the dates in SQLite in either ISO format or as integer (using seconds since epoch) and convert that back with the respective methods of QDateTime. Don't use local date formats as those vary from country to country and are hard to debug anyways. Storing the weekday in the database is redundant anyways.
  • [SOLVED] How to determine which OS is program runnig on?

    6
    0 Votes
    6 Posts
    5k Views
    D
    You can get more informations from QSysInfo if you have to distinguish further. Nevertheless you need the preprocessor symbols to use this class.
  • How to control TabBar width in MdiSubwindow

    4
    0 Votes
    4 Posts
    5k Views
    S
    When running the example I pasted above, do the tabs adjust to the length of the text? If so, can you modify the example so that it shows your problem? Which version of Qt are you using and on which platform?
  • How to read every nth row in Qt Sqlite?

    4
    0 Votes
    4 Posts
    8k Views
    A
    Thanks a lot guys, saved me lot of time.