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]QLineEdit With Model

    6
    0 Votes
    6 Posts
    8k Views
    M
    I think it needs a lot of work, anyway thank you Andre, that's what I was looking for.
  • Resize a QGraphicsItem into a QGraphicsScene

    2
    0 Votes
    2 Posts
    9k Views
    Z
    Here's one way to do it: Make your item selectable (setFlag()) If the item is selected, have your custom item class paint a resize handle in each corner and edge In your custom item class, override the mousePress(), mouseMove(), and mouseRelease() virtual functions. In the mousePress() function add code to check if the mouse press is over one of the handles. If it is set a flag that says you are in "resize mode". In the mouseMove() function, if you are in "resize mode" then resize (and maybe reposition) your item as determined by the moved amount. Remember to call prepareGeometryChange() to ensure the item gets repainted. In the mouseRelease() function flag that you are no longer in "resize mode". HTH.
  • Writing Data to a UDP socket error and stack error

    2
    0 Votes
    2 Posts
    3k Views
    F
    Could you show the class definition and the constructor? (or all the code, if you're at it, a zipped project is always good).
  • 0 Votes
    1 Posts
    3k Views
    No one has replied
  • [Solved] Fonts in Qt

    2
    0 Votes
    2 Posts
    5k Views
    EddyE
    I think you "have to read this :":http://doc.qt.nokia.com/4.7/qwidget.html#font-prop Especially this paragraph : bq. The current style, which is used to render the content of all standard Qt widgets, is free to choose to use the widget font, or in some cases, to ignore it (partially, or completely). In particular, certain styles like GTK style, Mac style, Windows XP, and Vista style, apply special modifications to the widget font to match the platform's native look and feel. Because of this, assigning properties to a widget's font is not guaranteed to change the appearance of the widget. Instead, you may choose to apply a styleSheet. Also the "QFont docs":http://developer.qt.nokia.com/doc/qt-4.7/qfont.html will explain this behaviour. In short : Qt tries to solve font issues for you that are not set by your theme/OS.
  • QFileDialog and file from a network

    3
    0 Votes
    3 Posts
    4k Views
    A
    If you use the static functions of QFileDialog, you get the native windows dialog. I think that that one does display your network neighbourhood or whatever it is called these days... You are not setting any properties that can not be set using the static function, so I would recommend you try those.
  • [Solved]can i delete a topic or a post

    7
    0 Votes
    7 Posts
    3k Views
    S
    [quote author="yan bellavance" date="1311201171"]got it, thanks![/quote] Kindly please edit the title of the thread to: [SOLVED] can i delete a topic or a post
  • 0 Votes
    5 Posts
    18k Views
    A
    Thanks Bradley!!! I guess that was what Andre implied but I was unaware of these functions.
  • Quick question!

    10
    0 Votes
    10 Posts
    5k Views
    S
    I would kindly like to propose the original poster to edit the title of the thread to something more informative. :-)
  • [Solved] Mapping a column from a table to a QComboBox

    10
    0 Votes
    10 Posts
    8k Views
    E
    It works fine now. First I've understood that a proxy model automatically ads an extra row. Now I added proxyModel->insertRow(0); and it works like I want. Thank you very much!
  • Writing QGraphicsItemGroup to a .png file?

    3
    0 Votes
    3 Posts
    2k Views
    J
    [quote author="kibsoft" date="1311145041"]Maybe something like that :) @ QImage img(item->boundingRect().size().toSize(), QImage::Format_RGB32); img.fill(QColor(255, 255, 255).rgb()); QPainter painter(&img;); QStyleOptionGraphicsItem styleOption; item->paint(&painter;, &styleOption;); img.save(path); @ where "item" is your QGraphicsItemGroup. P.S. I'm not sure, but you can try..[/quote] I tried doing that, but it doesn't work; it only returns a blank image that's the same dimension of the QGraphicsItemGroup.
  • QLineEdit && use popup similar to QCompleter

    5
    0 Votes
    5 Posts
    5k Views
    L
    [quote author="Alexandra" date="1311153765"]It doesn't seem to be a real duplicate, so I reopen it after discussion with other moderators. I'll edit the other thread to keep things clean. Thanks![/quote] Thanks!
  • OpenGL and Threads

    3
    0 Votes
    3 Posts
    3k Views
    Z
    I tried the makeCurrent but I got error. As suggested by pcpower in irc (thanks), I have changed my code, and now instead of display lists I'm using Virtual Buffer Objects, with QGLBuffer. If my code is not threaded everything is working fine, but when I run threads, the buffers are created by threads (without error), but nothing is displayed - I think its because they have different contexts. Here's a sample of my code: viewer.cpp: @ Viewer::Viewer(QWidget *parent) : QGLViewer(parent) {} void Viewer::draw() { for(int i=0; i<facesToDisplay; i++) faces[i]->draw(); } void Viewer::loadNeededFaces() { for(int i=0; i<totalFaces; i++) { if(faceIsNeeded(i)) QtConcurrent::run(this, &Viewer;::loadFace, i); } } void Viewer::loadFace(int faceNumber) { Face* face = new Face(faceNumber); face->createBuffer(); } @ Face.cpp @ void Face::createBuffer() { vertexBuffer = new QGLBuffer(QGLBuffer::VertexBuffer); vertexBuffer->create(); vertexBuffer->bind(); vertexBuffer->setUsagePattern(QGLBuffer::StaticDraw); vertexBuffer->allocate(vertexs, 3totalVerticessizeof(GLfloat)); } void Face::draw() { vertexBuffer->bind()) glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, BUFFER_OFFSET(0)); glDrawElements(GL_LINE_STRIP, 5, GL_UNSIGNED_INT, 0); glDrawArrays(GL_QUAD_STRIP, 0, totalVertices); glDisableClientState(GL_VERTEX_ARRAY); } @ The idea is to have a main GUI thread (instance of Viewer) to display the visible faces, and forecast the faces that will needed soon, to preload them using working threads, so when the user rotates the object, the faces that will appear are already precalculated (and possible in the GPU), so the loading will be smooth. The code isn't 100% correct, its just a sample of my code. Anyone can give me a hint on how to put that code working ? I think I need to get some context and then use makeCurrent. I have already tried to pass to the Face instance, a pointer to the Viewer, and then call the makeCurrent on that pointer, but with no success - "QGLContext::makeCurrent(): Failed."
  • 0 Votes
    6 Posts
    9k Views
    H
    Yes, thats exactly what I have done ;)
  • Quick Question Regarding Conversions in Qt [SOLVED]

    3
    0 Votes
    3 Posts
    2k Views
    G
    can you please show an example string that you get (in udpDataIn[61 - 64]) and show the expected result? It seems very difficult what you do there should be easier...
  • [SOLVED] How can I delete the content of a file with Qt ?

    5
    0 Votes
    5 Posts
    15k Views
    S
    Kindly please edit the title of the thread to begin with [SOLVED] ;-)
  • Dock widget resize. Many resize events.

    2
    0 Votes
    2 Posts
    3k Views
    F
    I think you should be able to use rubber band resizing, but I'm not sure how to do that and I didn't find it within five minutes :P. Normally I would say you should implement your paint event to only draw the exposed area, so take heed of the rectangle, or region passed to the paint event. It will significantly improve drawing performance in this case, as long as actually things are exposed. If you are going to be resizing a background there's not much use in this advice.
  • QScrollArea signal

    3
    0 Votes
    3 Posts
    4k Views
    E
    Thanks for the advices. I really thought Qt would manage the appearance of the scrollbar with signals. I'll try the eventfilter based in the showEvent.
  • Porting cocos2d to Qt

    3
    0 Votes
    3 Posts
    3k Views
    Q
    http://www.cocos2d-x.org/boards/6/topics/373 Here is the thread, it's porting cocos2d-x not cocos2d. I'd really love to see cocos2d on Qt. I would also love to help but I'm no expert in Qt. But at least I know the more than the basics in Qt and Objective-C, so if anyone would like to do this please let me know and I'll see what Can I do to help.
  • QPainterPath set operations deprecated in Qt 4.8

    7
    0 Votes
    7 Posts
    4k Views
    W
    Hrmm, I just noticed these were being deprecated. I'm going to really miss QPainterPath::setElementPositionAt. I use it to warp text to a curve. For example: @ QString text = "Sample string"; QFont font; QFontMetricsF fontMetric(font); qreal textWidth = fontMetric.boundingRect(text).width(); qreal circumfrance = 2PItextRadius; qreal textSweepAngle = (360.0 * textWidth) / circumfrance; QPainterPath path; path.addText(QPoint(0,0), scaledFont, text ); //warp points around a circle for (int i=0; i<path.elementCount(); i++) { const QPainterPath::Element &e = path.elementAt(i); qreal theta = MathTools::correctAngle(-90 + textSweepAnglee.x / textWidth; qreal r = textRadius - e.y; path.setElementPositionAt(i, rcos(theta), r*sin(theta)); } @ If QPainterPath::setelementPositionAt is going to be removed, won't it be impossible to warp text around a curve in Qt5? [EDIT: code formatting, please wrap in @-tags, Volker]