Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.7k Posts
  • How to create cube using opengl in qt

    3
    0 Votes
    3 Posts
    7k Views
    M
    hi some one please tell me i just created a cube in 3d. For small values of x,y co ordinates it is working fine for bigger values it is not showing cube. it is adding to the scene but i am unable to move my view to those co ordinates."graphicsview having fitInView .is there any similar funtion for QGLWidget" @ GLWidget::GLWidget(QWidget *parent) : QGLWidget(parent) { } void GLWidget::initializeGL() { glClearColor(1,1,1,1); glShadeModel(GL_FLAT); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); } void GLWidget::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glBegin(GL_QUADS); glEnd(); } void GLWidget::resizeGL(int w, int h) { double Aspect; if(h == 0) h = 1; glViewport(0, 0, w, h); Aspect=(double)w/(double)h; glMatrixMode(GL_PROJECTION); glLoadIdentity(); double Range = 10; if (w <= h) glOrtho(-(Range),Range,-Range/Aspect,Range/Aspect,-(Range*2),Range*2); else glOrtho(-(Range*Aspect),Range*Aspect,-Range,Range,-(Range*2),Range*2); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } @
  • Finding the center of QGraphicsPixmapItem

    4
    0 Votes
    4 Posts
    6k Views
    L
    OK, I think this is because you are creating a transformation instead of using the QGraphicsItem::rotate() function. If you create and set a transformation you probably have to do the translation (moving to the center and back) yourself. So probably not a bug, but could be better documented. Anyway, good that you found a way that works, even if it was not exactly what I suggested. :)
  • How to insert QProgressIndicator into QLineEdit?

    5
    0 Votes
    5 Posts
    3k Views
    R
    @void LineEdit::resizeEvent(QResizeEvent *) { QStyleOptionFrameV2 panel; initStyleOption(&panel); // the save as in the first post QRect rect = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this); progressIndicator->setFixedSize(rect.height(), rect.height()); progressIndicator->move(rect.x(), rect.y()); setStyleSheet(QString("padding-left: %1px;").arg(progressIndicator->width())); }@ Before first resize: !http://storage5.static.itmages.ru/i/12/0319/h_1332143675_5309478_7d93cf004c.png(before)! After: !http://storage9.static.itmages.ru/i/12/0319/h_1332143617_2963291_2d021625b1.png(after)!
  • When to set initial position of a toplevel QWidget?

    10
    0 Votes
    10 Posts
    11k Views
    A
    I must have made a mistake, because it worked when I retried it today. Thanks a lot!
  • Modeless dialog in Qt

    1
    0 Votes
    1 Posts
    3k Views
    No one has replied
  • MouseReleaseEvent only working for right button?

    3
    0 Votes
    3 Posts
    3k Views
    G
    Thanks! That worked! I had actually tried to use the event filter earlier, but it hadn't worked since I didn't know about installing it on the handle instead of in the splitter itself.
  • Connecting to sql express

    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • Unable to open database???

    2
    0 Votes
    2 Posts
    2k Views
    A
    Perhaps you should show us the real code, instead of a sequence of "what you entered".
  • Can't get dragging and dropping to work

    2
    0 Votes
    2 Posts
    2k Views
    X
    Hi again, Is all of this actually needed? I found on the internet (for example http://www.qtcentre.org/threads/9342-QGraphicsItem-itemIsMovable) that the movable flag should do the trick. So i removed all handlers from my scene and so on. The Point class now looks like: @ InterpolationPoint::InterpolationPoint(const MsVector& ref) : pos(ref), iD(i++), hpos(2,1) { setAcceptedMouseButtons(Qt::LeftButton); setCursor(Qt::OpenHandCursor); setFlag(QGraphicsItem::ItemIsMovable, true); } InterpolationPoint::~InterpolationPoint() { } QRectF InterpolationPoint::boundingRect() const { return QRectF(-5, -5, 10, 10); } void InterpolationPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); painter->setPen(QPen(Qt::black, 1)); painter->setBrush(Qt::SolidPattern); painter->drawEllipse(-2, -2, 4, 4); setPos(QPointFVec(pos)); } @ Moving the itemismovable into the paint didn't fix the problem for me, I can not move the point across the scene which is basically all I want: movable points, they do not need to drop a shadow or whatever, just movable. How can I achieve this?
  • Qstring Problem

    5
    0 Votes
    5 Posts
    2k Views
    K
    [quote author="poporacer" date="1332042095"] QString y = str1.mid(1, 6);[/quote] This is the right approach, but it should be: @ QString y = str1.mid(2, 6);@
  • Two bugs of qt creator mac version

    2
    0 Votes
    2 Posts
    1k Views
    K
    welcome to devnet Reporting bugs here is of no help. There is "JIRA":https://bugreports.qt-project.org/secure/Dashboard.jspa available to report bugs.
  • [SOLVED] What are properties for?

    7
    0 Votes
    7 Posts
    3k Views
    P
    Ok, so it sounds like this code doesn't need properties to function. It seems needlessly complicated for a textbook example, but oh well.
  • Switching language

    6
    0 Votes
    6 Posts
    3k Views
    M
    Good every one! I found one book! "Advanced Programming in the UNIX® Environment: Second Edition" By W. Richard Stevens, Stephen A. Rago
  • Write data to a MySQL database [Solved]

    5
    0 Votes
    5 Posts
    2k Views
    S
    Hi connect to database @ dBase = QSqlDatabase::addDatabase("QMYSQL"); dBase.setDatabaseName("name_database"); dBase.setHostName("127.0.0.1"); // ip or host dBase.setUserName("root"); //user_name dBase.setPassword("pass"); // dBase.open(); @ and with a requests to write or read data from database. For help read this "tread":http://qt-project.org/forums/viewthread/15037/
  • How to capture Qlabel link text and redirect it to my use

    2
    0 Votes
    2 Posts
    2k Views
    L
    Set "QLabel::openExternalLinks":http://qt-project.org/doc/qt-4.8/qlabel.html#openExternalLinks-prop to false and connect to the "QLabel::linkActivated()"::http://qt-project.org/doc/qt-4.8/qlabel.html#linkActivated signal.
  • Using Qt to generate stringlist combinations

    6
    0 Votes
    6 Posts
    4k Views
    J
    Brain to terminal ( not tested and this may be completely wrong ;) ): @// input is index of desired sequnce QString CNemelyGen::getSequnceNr(int sqNr) { // storage for indexes of strings QVector<int> tmpIndex; // size list -> class variable QVector, to store sizes of strings for(int i=0; i<sizeList.size(); i++) { // Calculates index of current argument sequnces tmpIndex.append(sqNr%sizeList[i]); sqNr%=sizeList[i]; } // String that will be returned QString retSqString; // generates string based on index for(int i=0; i<stringList.size(); i++) { // Gets character in each string and append it at end of return string retSqString.append(stringList.at[i].at(tmpIndex[i])); } return retSqString; }@ And as for next(), add tmpIndex to class instead of function. And only add one to last index ( make sure to check if last index isn't maxed out ( last possible index), if it is, reset it to zero, and ++ one before. And check again if it's the last one etc...) Hope that provided comments will be enough. Regards, Jake
  • [Solved]Dictionary search

    5
    0 Votes
    5 Posts
    2k Views
    M
    Thanks just before i jump into it is this what you meant? [code]QHash <QString, QString> dictionary;[/code] [edit] Andre thank you a lot it works like a charm =]
  • [SOLVED] A question on QObject child deletion

    5
    0 Votes
    5 Posts
    4k Views
    ?
    Yes, I noticed it is pretty straightforward, not that I didn't trust you :P
  • Object::connect: No such slot QApplication::foo

    6
    0 Votes
    6 Posts
    6k Views
    M
    Wahhh. Finally I have figured out what caused the problem. The imageGrabberChanged method gets called before the m_eggFinder instance created. I have no idea why did not caused SIGSEV ever. Thank you very much for your help!
  • USB storage cross-platform support?

    4
    0 Votes
    4 Posts
    4k Views
    A
    Note that there is code in QtMobility (that should work just fine on the desktop as well) to enumerate system drives.