Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.4k Posts
  • [Solved] Add Coloumn to QTableWidgetItem

    3
    0 Votes
    3 Posts
    10k Views
    S
    thanks for reply. solved.
  • How to Use QFileSystemModel

    2
    0 Votes
    2 Posts
    2k Views
    frankcyblogic.deF
    Leave it. (If you want to have some fun, try to delete or move the directory it is watching;)
  • How to set orientation of text in horizontal header ?

    18
    0 Votes
    18 Posts
    20k Views
    A
    I found some way to solve this in table widget which I use: @QHeaderView * header = m_ui->tableWidget->horizontalHeader(); int columnCnt = m_ui->tableWidget->columnCount(); int width = header->width()/columnCnt; int height = header->height(); for(int i = 0; i<columnCnt; i++) { QTableWidgetItem * item = m_ui->tableWidget->horizontalHeaderItem(i); if(item == NULL) continue; QVariant data = item->data(Qt::DisplayRole); if (data.isValid()) { QString text=data.toString(); item->setData(Qt::DisplayRole, ""); QPixmap original_button(width, height); QPainter original_button_painter(&original_button); /* QHeaderView::paintSection(&original_button_painter, QRect(0, 0, width, height), i);*/ QPixmap pix(width, height); QPainter p(&pix); p.drawPixmap(0, 0, original_button); QRect new_r(0, 0, height, width); QMatrix m; m.translate(0, height); m.rotate(-90); p.setWorldMatrix(m, true); p.drawText(new_r, Qt::AlignCenter, text); item->setIcon(pix); item->setSizeHint(QSize( height, width )); } }@ This code I place on my dialog which holds table widget in ui file. So the only one question is how to set true sizes of the text? It looks smaller then text in vertical header. Waiting for your code critic and propositions.
  • QTimer help needed

    20
    0 Votes
    20 Posts
    9k Views
    Z
    And perhaps even more important is then the emerging understanding from reading and digesting such examples. This then allows you to apply techniques and particular building blocks in other situations. Learning should also be fun. Do not be afraid to experiment on your own.
  • Data of QTreeView rows

    2
    0 Votes
    2 Posts
    5k Views
    G
    You connect a slot to signal "doubleClicked() ":http://doc.qt.nokia.com/4.7/qabstractitemview.html#doubleClicked. The model index contains parent, row and column of the model index clicked. In your slot, you can get the current values via @ int row = index.row(); QModelIndex parent = index.parent(); QString str0 = model->data(model->index(row, 0, parent), Qt::EditRole); QString str1 = model->data(model->index(row, 1, parent), Qt::EditRole); QString str2 = model->data(model->index(row, 2, parent), Qt::EditRole); @
  • Connect not declared in this scope

    4
    0 Votes
    4 Posts
    53k Views
    N
    @VCsala :thanks that resolve my problem , but what i didn't understand is i already test it.
  • Qt libraries 4.7.2 for Windows (Visual Studio 2008)

    4
    0 Votes
    4 Posts
    3k Views
    K
    The only one who may be able to answer your question without any doubts is the engineer running the scripts. However, see it from a logical viewpoint. It is not logical to build different versions not observing the default values. There might be exceptions for specific platforms, but I would not expect it for desptop builds. The default values are set to represent the typical values for compilation. If the Qt engineers would do different it would create quite a mess for them. If you want to make very sure what you have, you have to generate the build yourself. That is the only recommendation I can give you. It takes a bit of time, but it worked so far for me.
  • Wordundercursor in QPlainTextEdit

    4
    0 Votes
    4 Posts
    3k Views
    D
    Yes, but you have to use QTextEdit::ExtraSelection() to tell QTextEdit which are the words that are going to be highlighted. Check out the link I mentioned... that is an IDE, where in that method the functionality that you mentioned is applied.
  • How to creating a text editor using qt creator?

    3
    0 Votes
    3 Posts
    4k Views
    T
    If this is just about making Qt Creator more lightweight, then you can just disable plugins you do not care about (Check Help->About Plugins). If you want to have a stand-alone text editor with all the bells and whistles Qt Creator has for C++/QML/Javascript/GLSL, then you need to be aware that this functionality requires quite a bit of infrastructure: Creator needs to know a lot to make that possible! This includes (but is not limited to) all the files that belong to a project, the location of header files, even the compiler that will be used to build. So removing that code will reduce the editors functionality. The code of Qt Creator is available on "gitorious":https://qt.gitorious.org/qt-creator. The plugins in src/plugins/*editor (there are quite a few different ones by now:-) are the most interesting if you want to know about the editors.
  • Using QFileDialog to select a project directory

    7
    0 Votes
    7 Posts
    12k Views
    V
    You can also add the option QFileDialog::ShowDirsOnly.
  • QtNetwork/QUdpSocket

    5
    0 Votes
    5 Posts
    3k Views
    D
    Yep, best solution will be to have fixed port for receiving answers on your client side.
  • Using QScript to manipulate and pass large arrays

    4
    0 Votes
    4 Posts
    3k Views
    frankcyblogic.deF
    Jitting is enabled by default. Would like to know how it impacts performance in your example! Never tried QScriptProgram myself;)
  • Duck Hunt Game create -> Qtimer help

    Locked
    2
    0 Votes
    2 Posts
    2k Views
    A
    This looks like the same discussion as "this topic":http://developer.qt.nokia.com/forums/viewthread/5443/. Closing.
  • Signal/Slot between a form class and the main window class

    10
    0 Votes
    10 Posts
    21k Views
    A
    I am really sorry, but I don't follow it anymore. The code you show above seems fine in terms of operation order, though there is a problem with ownership. Who will delete the NewForm object you created? How about these modifications to your code: Make your NewForm pointer a private member of your VCMainWindow class. Initialize the NewForm pointer to 0 in your VCMainWindow constructor. Only create a new instance of VCMPDataInputForm if there isn't one already. In your CreateNewDataTab() slot, use the now available NewForm member pointer to access the VCMPDataInputForm class instance. Add a member function (GetFromData() will serve, I guess) to VCMPDataInputForm to access the form data, so you can get to it from the CreateNewTab slot. This way, you only access the form data if the form was accepted. No new tab will be created if the dialog was cancelled.
  • [Help] Async Client-Server protocol handling.

    3
    0 Votes
    3 Posts
    3k Views
    A
    I would try to avoid the trick Volker mentions. Instead, I would add additional information to your QNetworkReply instance that helps you to work with it in an asynchronic way. One way to do that, is to simply recognize that QNetworkReply is a QObject, and that QObject has a feature called dynamic properties. So you can simply do something like this: @ //stole sample code from Volker above :-) QNetworkAccessManager *nam = new QNetworkAccessManager(); QNetworkRequest req; // assemble your request here QNetworkReply *reply = nam->get(req); reply->setProperty("requestType", "startSession"); //add any other data you may need @ And then later, when the reply comes in, use it like this: @ //method handing the QNAM reply: //reply is of type QNetworkReply again QString requestType = reply.property("requestType").toString(); if (requestType == "startSession") { handleStartSessionReply(reply); } else if (requestType == "getToken") { handleGetTopenReply(reply); } // etc. @ There are other ways of course, like keeping a hash like this: @ QHash<QNetworkReply*, MyNetworkRequestDataStruct> m_networkRequestMetaData; @ The MyNetworkRequestDataStruct can then include any metadata that you might want to keep around about your network request.
  • Connection problem

    5
    0 Votes
    5 Posts
    2k Views
    A
    Even the last one is lost, as the manager pointer is out of scope after the loop and can not be referenced anymore after the loop has ended.
  • Uncompress problem with quazip

    3
    0 Votes
    3 Posts
    3k Views
    G
    Sorry, this is not an Qt issue. You should ask the folks at http://quazip.sourceforge.net for some support. A quick look shows that they did not any tests on Mac OS X yet - I'm sure they love to hear from your experiences.
  • Sideconditions in QDir-constructor?

    4
    0 Votes
    4 Posts
    2k Views
    J
    Thanks to both of you for your fast replies! Though I don´t like your answers (just kidding :D). As I´m working on Windows (and using Netbeans, which somehow does not really help me debugging), I´ll install a virtual machine to examine my code properly. I´ll report, when I´ve got some new findings (or questions).
  • QMovie help

    3
    0 Votes
    3 Posts
    4k Views
    A
    This has nothing to do with QMovie. Just use a layout to manage the geometry of your widget. You can position the label any place you want it in the parent widget. It seems that you already are using Qt Designer and ui files. Why not add the QLabel you want to use for your movie there, put it in the layout you like, and simply reference the label instead of creating a new one in the code you are showing?
  • Why QLineEdit's setInputMask is removing spaces?

    7
    0 Votes
    7 Posts
    9k Views
    S
    Thanks for modifying the example. This is the expected behavior of setInputMask(). Space is the default blank character and the blank characters are always removed from the text after editing, as Volker pointed out. If you want to save the spaces then you should call setValidator () on the line edit and use a QRegExpValidator instead. This will allow you to have better control of what the text looks like. See the documentation: http://doc.trolltech.com/4.7/qlineedit.html#setValidator http://doc.trolltech.com/4.7/qregexpvalidator.html